ImportError: No module named Foundation ImportError: No module named Foundation xcode xcode

ImportError: No module named Foundation


I had the same problem. Mine was caused I think by using homebrew to install my own Python to tinker with.

Because I was worried about mixing python versions, rather than creating the link as described above, I installed a new pyobjc using:

$ pip install pyobjc

For interest, from (http://pythonhosted.org/pyobjc/)

The PyObjC project aims to provide a bridge between the Python and Objective-C programming languages.


Okay, it turned out that, amending mjv's answer, I was able to get it working by typing

export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PyObjC/"

before executing the ./project-tool.py line. I still find it ridiculous that I had to do this and if anyone can see why, I would be delighted to know.

Doing this also got the

>>> import objc

line working.


It's because PyObjC is there :/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC

Edit :I found how to make "import objc" work, just :export PYTHONPATH="/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/"

It will add all the directories to the python path (sys.path)