Thanks Ron.

For the benefit of other newbies like me: I downloaded the pyobjc-core tarball from http://pypi.python.org/pypi/pyobjc-core/2.2, cd'ed into the unzipped directory and then did the usual sudo setup.py install. PyObjC is behaving well for me now as I work through the excellent tutorial http://lethain.com/entry/2008/aug/22/an-epic-introduction-to-pyobjc-and-cocoa/ .

Glenn

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


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

Hi,

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 "main.py", 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/__init__.py", line 22, in <module>
    _update()
  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/__init__.py", 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/_objc.so, 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/_objc.so
  Reason: Incompatible library version: _objc.so 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/py1.app/Contents/Resources/main.py'.  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 _objc.so 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 :-(

Ronald