问题
I am new to Python. I am running Mac OS X 10.8.2, Python 2.7.3, Xcode 4.5.1.
I am not able to import pyobjc
to python.I used easy_install pyobjc
or manually downloading it from http://pypi.python.org/pypi/pyobjc/2.3 and running python setup.py install
. Here is a screenshot of my site-packages folder

How do I solve this?
Here is a screenshot of sys.path.PyOBJc is present in sys.path

回答1:
I don't see a .pth
file for pyobjc
in your site-packages
directory there.
.pth
files, placed inside a directory already on Python's search path, contain directories to add to that search path. They're simple text files; you can review the ones already there to get a feel for how they work.
As to why you didn't get .pth
files for pyobjc
, I'm not sure. But you could create some to fix the problem up.
Further reading: Modifying Python’s Search Path
回答2:
The module name for PyObjC is not "pyobjc".
To use the low-level bridge use "import objc"
To access the Cocoa framework use "import Cocoa".
If "import objc" gives an import error you probably have a number of Python interpreters, check if the value of "sys.prefix" is what you expect it to be. Also check if "/Library/Frameworks/Python.framework/Version/2.7/lib/python2.7/site-packages" is on "sys.path".
来源:https://stackoverflow.com/questions/12864650/importerror-no-module-named-pyobjc