Skip to main content
 首页 » 编程设计

python之libtorrent-rasterbar 的 python 绑定(bind)是否适用于 Python 3

2024年11月01日8jiqing9006

我安装了 Python 3.4(32 位),并在此基础上安装了 python-libtorrent-0.16.16.win32.msi。

我的测试代码说: ImportError:DLL 加载失败:%1 不是有效的 Win32 应用程序。

我的谷歌搜索结果表明这适用于 Python 2.7。那是解决方案吗?我必须降级我的 Python 吗?

请您参考如下方法:

没有。 Libtorrent 不支持 Python 3。

它编译但由于 Python 3 utf8 处理差异而无法工作。 有一段时间没有成功让它工作 https://code.google.com/p/libtorrent/issues/detail?id=449

当前主干甚至包含无效的 Python 3,即 http://sourceforge.net/p/libtorrent/code/HEAD/tree/trunk/bindings/python/setup.py 第 70 行 > '打印命令行'

由于某种原因,有一个 Ubuntu python3-libtorrent 包使人感到困惑,但它肯定不起作用,手动编译也不行。

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"