python - 未找到 libtorrent 模块

标签 python python-3.x google-colaboratory libtorrent

我使用此代码从 torrent 下载并使用 google colab 进行驱动

1   !apt install python3-libtorrent
2
3   import libtorrent as lt
4 
5   ses = lt.session()
6   ses.listen_on(6881, 6891)
7   downloads = []

第 3 行出现错误:

ModuleNotFoundError: No module named 'libtorrent'  

完整的输出是

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-libtorrent is already the newest version (1.1.5-1build1).
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-1098f0f9d9d1> in <module>()
      1 get_ipython().system('apt install python3-libtorrent')
      2 
----> 3 import libtorrent as lt
      4 
      5 ses = lt.session()

ModuleNotFoundError: No module named 'libtorrent'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

我尝试使用 pip 而不是 apt,但没有成功。 还有另一个错误说:

找不到满足 python3-libtorrent 要求的版本(来自版本:无) 找不到 python3-libtorrent 的匹配发行版

输出是

ERROR: Could not find a version that satisfies the requirement python3-libtorrent (from versions: none)
ERROR: No matching distribution found for python3-libtorrent
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-b9ec203eb952> in <module>()
      1 get_ipython().system('pip install python3-libtorrent')
      2 
----> 3 import libtorrent as lt
      4 
      5 ses = lt.session()

ModuleNotFoundError: No module named 'libtorrent'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

最佳答案

请点击下面给出的 YouTube 链接。这会对你有帮助。

https://youtu.be/kFG2YHVGZLs

简单来说,只需在“!apt install python3-libtorrent”前添加以下两行即可

!python -m pip install --升级 pip setuptools 轮

!python -m pip install lbry-libtorrent

关于python - 未找到 libtorrent 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66364850/

相关文章:

python - 计算每行的字数

python-3.x - 尝试在Python 3中使用原始套接字盲目发送IP程序包,但不断获取ARP查询如何禁用

python - Google colab Glove_Python pip 安装不起作用

python - Django - 通过表单更新用户实例

python - 使用一个字典对列表列表的不同元素求和 (Python)

python - 如何使用 Python 复制 xml 元素?

python - 计算表中每 x 行的平均值并创建新表

python - 从 FFProbe STDERR 打印字符串时输出错误

deep-learning - 使用 colab 和 fastai 的训练问题(第一个 epoch 需要很长时间超过 4 小时)

python - Google Colab 无法更改 Python 版本