Thanks Ron.

For the benefit of other newbies like me: I downloaded the pyobjc-core tarball from, cd'ed into the unzipped directory and then did the usual sudo install. PyObjC is behaving well for me now as I work through the excellent tutorial .


On Dec 8, 2009, at 12:38 PM, Ronald Oussoren wrote:

On 8 Dec, 2009, at 19:50, Glenn wrote:


I've done a framework install of Python 2.6 on OSX10.5 and it works just fine. 

To enable Cocoa/Python apps, I've installed pyobjc 2.2 and that works well enough that the native MacOSX backend in matplotlib runs properly.

However, when I try running my own app with Xcode, I get the following traceback: 

[Session started at 2009-12-08 10:24:30 -0800.]
Traceback (most recent call last):
  File "", line 10, in <module>
    import objc
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.3-fat.egg/objc/", line 22, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.3-fat.egg/objc/", line 19, in _update
    import _objc
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.3-fat.egg/objc/, 2): Library not loaded: /usr/lib/libxml2.2.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.3-fat.egg/objc/
  Reason: Incompatible library version: requires version 10.0.0 or later, but libxml2.2.dylib provides version 9.0.0
2009-12-08 10:24:30.364 py1[960:10b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '/Users/glenn/learningcocoa/py1/main.m:44 main() PyRun_SimpleFile failed with file '/Users/glenn/learningcocoa/py1/build/Debug/'.  See console for errors.'

So, to fix this, I installed the latest version of libxml2.2.dylib in /usr/local/lib. Unfortunately, subsequent installation of the latest distribution of Pyobjc doesn't fix the problem:

easy_install pyobjc==2.2  =>  /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.3-fat.egg

because that contains a precompiled that is linked to /usr/lib/libxml2.2.dylib.

What is the canonical way to get a framework install of pyobjc 2.2 working properly in Python 2.6 on OS-X 10.5? I've read horror stories about breaking system apps if /usr/lib/libxml2.2.dylib is messed with.

The release binaries were created on 10.6, which appearently ships with an updated version of libxml.

The easiest workaround for now is to download the source archive of pyobjc-core and install that, easy_install pyobjc==2.2 should then install the framework wrappers.

What really sucks is that both the 10.5 and 10.6 versions of libxml are of the 2.2 branch of libxml, which AFAIK should be binary compatible :-(