Skip navigation
This discussion is archived

XCode 3.0 cocoa-python app throws exception when importing objc

1172 Views 5 Replies Latest reply: Mar 31, 2009 10:26 AM by keeler1 RSS
keeler1 Calculating status...
Currently Being Moderated
Mar 30, 2009 9:55 AM
I have created the default cocoa-python application in xcode. I then try and run it and it says that an exception was thrown. I search back through the console and apparently it could not find the module objc.

After searching for reasons it is apparently because there are two Python frameworks installed. One in /System/Library/Frameworks and the other in /Library/Frameworks. The one in /Library/Frameworks does not have PyObjC installed for it.

However, in my xcode proj under linked Frameworks, it points to the python framework in /System/Library/Frameworks which has objc installed. Is there any reason. So apparently when it is running it, it decides not to used that linked framework but the other one without objc instead.

Would the best thing to do be, to delete the alternative python framework in /Library/Frameworks, or is there a better solution.
13" unibody Macbook, Mac OS X (10.5.6)
  • orangekay Level 5 Level 5 (4,085 points)
    Xcode has no impact on Python's include paths. You clearly installed another version and modified your settings.
    Several, Mac OS X (10.5.2)
  • hhas Level 2 Level 2 (190 points)
    The Python-Cocoa Xcode templates are crap - they just link whatever Python framework appears first on the host system's search path, regardless of whether or not it's the one you built against (i.e. Apple's). Either bind Apple's Python.framework yourself (see CFBundleGetFunctionPointerForName), or skip Xcode and use py2app to build a standalone application bundle with all dependencies included (this is what I do).
  • hhas Level 2 Level 2 (190 points)
    keeler1 wrote:
    Are there any good PyObjC tutorials, preferably ones that do not use xcode.


    I don't have any recommendations to hand, but I imagine a web search should turn up something. I know the Prags have a book on RubyCocoa coming out, but I doubt that'll be much interest if Python's your thing. Personally, I learnt PyObjC by reading up on ObjC basics so I could follow the Cocoa documentation, then playing around with the sample projects included with PyObjC. PyObjC development is pretty much just regular Cocoa development with a thin glue layer on top. There's py2app documentation online if you need it, and again the easiest thing is just to start with the existing examples and modify to suit.

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.