I'm on Mac OS X 10.6. Python is 2.6.1.
I've installed bencode module as
sudo easy_install BitTorrent-bencode
It appeared in site-packages
/Library/Python/2.6/site-packages/BitTorrent_bencode-5.0.8-py2.6.egg
But, how to import and use this module?
>>> import bencode
doesn't work…
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bencode
How to import modules from site-packages?
How to recognize module name BitTorrent_bencode-5.0.8-py2.6.egg contains?
sys.path
['', '/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/Versions/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/Library/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/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode']
Thanks
Best Answer
The BitTorrent_bencode-5.0.8-py2.4.egg is broken. If you use unzip to look at the contents of the egg you'll see:
Notice that bencode.py and BTL.py are not included. If you download the source distribution for the package from pypi, you can get the missing files. The problem with the package is that the setup.py does not include the root directory of the distribution in the list of packages that the egg is created by. To fix this you could edit setup.py and replace the line that says:
with:
Then, running
python setup.py install
will correctly install the package.