Installing PyObjC in virtualenv on Mac OS X 10.7

Installing PyObjC in a new Python virtualenv on Mac OS X 10.7 can be a little tricky.

Here are the problems I ran into. First, pip wouldn’t install pyobjc-core nor pyobjc. Turns out pyobjc does some specialised installation stuff not compatible with pip. The error looks like this:

AttributeError: class egg_info has no attribute 'iter_entry_points'

The answer is just to switch to easy_install.

The second error is a compilation error:

Modules/objc/alloc_hack.m: In function ‘call_NSObject_alloc’:
Modules/objc/alloc_hack.m:33: error: Mac OS X version 10.5 or later is
needed for zerocost-exceptions

Not sure what’s going on here but Googling the error indicated it potentially has to do with compiling for a 64 bit platform. Regardless the solution is to change deployment target like so:

export MACOSX_DEPLOYMENT_TARGET=10.5

All in all this is what we get:

mkvirtualenv myenv
export MACOSX_DEPLOYMENT_TARGET=10.5
easy_install pyobjc-core
easy_install pyobjc

Good luck!

Subscribe Tweet This
Written by Alexander Ljungberg on 2012 May 15 .
Tagged .