Search code examples
pythonmoduleosx-snow-leopardpyobjc

Can import objc module in python 2.6 but NOT in python 2.7


My system: Mac OS X 10.6.8, gcc 4.2, python 2.7, xcode 3.2.3

I use python 2.7 and I got error when tried to do: import objc, it returns: ImportError: No module named objc.

It looks like the objc module is not there. But actually I have the objc module installed already. Snow Leopard has got pyobjc preinstalled and I have also checked this using python2.6 (I have python 2.7 and 2.6 in my Mac). So if I invoke import objc using python2.6, I got no error which means objc exists and I can use that module without problems ... but if I import using python 2.7, I will got the ImportError: No module named objc error.

Does anyone have any solution? FYI, the python2.6 is coming preinstalled with OS X while 2.7 is manually installed. I've been using the 2.7 for couple of months without problems.


Solution

  • Python C extension modules like objc cannot be re-used between python versions. You'll have to install the objc module for 2.7 separately.

    Generally, different python installations (such as 2.6 or 2.7, or 3.2) use separate module import locations, and you normally install extensions per python setup.