ImportError:没有名为Foundation的模块

时间:2010-06-23 04:26:28

标签: python pyobjc

嘿所有,我对python很新,所以请耐心等待。

我想使用PyObjC的一些组件编写一个简单的脚本。我在Mac OS 10.5上运行,所以从我读过的内容来看,它已包含在内。

然而,打开一个简单的python提示并输入import Foundation会给我一个错误ImportError: No module named Foundation

作为参考,我的sys.path是

['', '/var/hg/lib/python2.4/site-packages', '/Users/dmitri/lib/python', 
'/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/PyObjC', 
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PyObjC', 
'/Users/dmitri', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip', 
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5', 
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin', 
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac', 
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages', 
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk', 
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload', 
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages']

'/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/PyObjC','/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PyObjC',进入那里因为我在鬼混,但他们似乎没有帮助我。 2.4版本似乎存在,但在2.5版本中似乎没有上述路径的文件夹。

2 个答案:

答案 0 :(得分:4)

我找到了 - 出于某种原因,它位于/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python下,所以我只需将整个目录添加到我的$PYTHONPATH

答案 1 :(得分:0)

模块Foundation位于何处?假设它与PyObjC - /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/位于同一位置 - 那么您还必须将/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/添加到$PYTHONPATH