2

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

我的测试代码说: ImportError: DLL load failed: %1 is not an valid Win32 application。

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

4

2 回答 2

1

不。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 行 > 'print cmdline'

出于某种原因,有一个 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"
于 2014-07-04T17:50:00.997 回答
0

它确实支持python3

这个 docker 文件对我有用(libtorrent- 带有 lib 的本地目录已检出为所需的版本)

FROM debian:buster-slim

WORKDIR /app/libtorrent
COPY debian/backports.list /etc/apt/sources.list.d/
RUN apt-get update
RUN apt-get install -y -t buster-backports checkinstall
RUN apt-get install -y build-essential libboost-system-dev libboost-python-dev libboost-chrono-dev libboost-random-dev libssl-dev
RUN apt-get install -y autoconf automake libtool
ADD libtorrent /app/libtorrent
RUN ./autotool.sh
# RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1
ENV PYTHON=/usr/bin/python3.7
RUN ./configure --enable-python-binding --with-libiconv
RUN make
RUN checkinstall
RUN ldconfig

于 2020-03-18T10:39:57.983 回答