导入错误:没有名为 Foundation 的模块

发布于 2024-09-07 08:32:41 字数 1451 浏览 6 评论 0原文

大家好,我对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情深如许 2024-09-14 08:32:41

我找到了它 - 由于某种原因,它位于 /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

夏夜暖风 2024-09-14 08:32:41

模块 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 as PyObjC -- /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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文