【发布时间】:2011-02-11 05:53:39
【问题描述】:
我使用的是 Mac OS X 10.6。 Python 是 2.6.1。 我已将 bencode 模块安装为
sudo easy_install BitTorrent-bencode
它出现在站点包中
/Library/Python/2.6/site-packages/BitTorrent_bencode-5.0.8-py2.6.egg
但是,如何导入和使用这个模块呢?
>>> import bencode
没用……
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bencode
如何从站点包中导入模块? 如何识别 BitTorrent_bencode-5.0.8-py2.6.egg 包含的模块名称?
系统路径 ['', '/Library/Python/2.6/site-packages/BitTorrent_bencode-5.0.8-py2.6.egg', '/Library/Python/2.6/site-packages', '/System/Library/Frameworks/ Python.framework/Versions/2.6/lib/python26.zip', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/版本/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/Library/Frameworks/ Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', '/System/库/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk','/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC ', '/System/Library/Frameworks/Python.framework/Version s/2.6/Extras/lib/python/wx-2.8-mac-unicode']
谢谢
【问题讨论】: