导入错误:没有名为 Foundation 的模块
大家好,我对 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 版本中似乎没有包含上述路径的文件夹。
Hey all, I'm pretty new to python, so bear with me.
I want to write a simple script using some components of PyObjC. I'm running on Mac OS 10.5, so from what I've read, it's included.
However, opening up a simple python prompt and typing import Foundation
gives me the error ImportError: No module named Foundation
.
For reference, my sys.path is
['', '/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',
and '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PyObjC',
got in there because I was fooling around, but they don't seem to help me. The 2.4 version seems to exists but there, seems to be no folder with the aforementioned path in the 2.5 version.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了它 - 由于某种原因,它位于
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python
下,所以我必须将整个目录添加到我的$PYTHONPATH
I found it - for some reason, it was located under
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python
, so I had to just add that whole directory to my$PYTHONPATH
模块
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
中。Where is the module
Foundation
located? Assuming it's in the same place asPyObjC
--/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/
-- then you have to add/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/
to your$PYTHONPATH
as well.