【问题标题】:libtorrent module not found未找到 libtorrent 模块
【发布时间】:2021-05-27 14:19:03
【问题描述】:

我使用此代码从 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.
---------------------------------------------------------------------------

【问题讨论】:

  • 使用pip 而不是apt。我不确定为什么 apt 不起作用,但 pip 绝对应该

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


【解决方案1】:

请按照下面给出的 YouTube 链接进行操作。这会对您有所帮助。

https://youtu.be/kFG2YHVGZLs

简单来说就是在"!apt install python3-libtorrent"前加上下面两行

!python -m pip install --upgrade pip setuptools wheel

!python -m pip install lbry-libtorrent

【讨论】:

  • 您能否将解决方案的摘要作为您答案的一部分发布,以便在链接更改或被删除的情况下,用户仍然可以找到相关答案?
猜你喜欢
  • 2018-04-15
  • 2020-09-28
  • 2019-09-11
  • 1970-01-01
  • 2020-09-24
  • 2019-09-23
  • 2018-10-23
相关资源
最近更新 更多