Do the python bindings for libtorrent-rasterbar wo

2019-07-18 15:51发布

问题:

I have Python 3.4 (32-bit) installed, and I installed the python-libtorrent-0.16.16.win32.msi on top of that.

My test code says: ImportError: DLL load failed: %1 is not a valid Win32 application.

My google results suggest this works fine with Python 2.7. Is that the solution? I have to down-grade my Python?

回答1:

NO. Libtorrent doesn't support Python 3.

It compiles but doesn't work due to Python 3 utf8 handling difference. There was an unsuccessful effort to make it work a while back https://code.google.com/p/libtorrent/issues/detail?id=449

Current trunk even contains invalid Python 3 i.e. http://sourceforge.net/p/libtorrent/code/HEAD/tree/trunk/bindings/python/setup.py Line 70 > 'print cmdline'

For some reason there is an Ubuntu python3-libtorrent package which confuses people, but it definitely doesn't work, neither does manual compilation.

steps:
apt-get build-dep libtorrent-rasterbar
export 'PYTHON_VERSION=3.4'; export 'PYTHON=/usr/bin/python3.34'
./configure LDFLAGS="-L/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu/" --enable-python-binding --enable-geoip=no
--with-boost-python=boost_python-py34
ldconfig

>> python
import libtorrent
ses = libtorrent.session()
ses.save_state()

"UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 0: invalid start byte"