Installing libtorrent on Linux
Libtorrent by Rasterbar is a C++ BitTorrent library with Python bindings.
Installing libtorrent for Python requires only one shell command
sudo apt-get install python-libtorrent
but building from the source (if you want to make any modifications) requires a little more work.
Apt-Get is the easiest way to install all the dependencies.
sudo apt-get build-dep python-libtorrent
Grab the latest released tarball from here and build.
tar -zxvf libtorrent-rasterbar-0.16.9.tar.gz
cd libtorrent-rasterbar-0.16.9
./configure --enable-python-binding
make
sudo make install
You may see the following output:
---------------------------------------------------------
Libraries have been installed in:
/usr/local/lib
...
---------------------------------------------------------
Add this directory to your path. (You may consider adding it to your ~/.profile
.)
export LD_LIBRARY_PATH=/usr/local/lib/
Now build the Python bindings.
cd bindings/python
python setup.py build
sudo python setup.py install
Then try importing the library in Python.
>>> import libtorrent
>>>
If it imports libtorrent
without complaints, you are DONE!
If Python can't open the shared object file, it isn't looking in the right place.
>>> import libtorrent
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libtorrent-rasterbar.so.7: cannot open shared object file: No such file or directory
>>>
You can search for the shared object file
sudo updatedb
locate libtorrent-rasterbar.so.7
which should output the location.
/<path_to_directory>/libtorrent-rasterbar.so.7
Add the enclosing directory to your path
export LD_LIBRARY_PATH=/<path_to_directory>/
and try importing libtorrent
again.
Written by Steely Morneau
Related protips
1 Response
Cool! I've searching a tutorial like this for days!