【问题标题】:ModuleNotFoundError: No module named 'libtorrent'ModuleNotFoundError:没有名为“libtorrent”的模块
【发布时间】:2021-05-27 10:30:19
【问题描述】:

我尝试在 google colabratory 中运行以下代码:

!apt install python3-libtorrent

import libtorrent as lt
ses = lt.session()
ses.listen_on(6881, 6891)
downloads = []

我可以install python3-libtorrent。但是我无法导入 libtorrent。它显示ModuleNotFoundError: No module named 'libtorrent'。它显示第二个代码错误,即“import libtorrent as lt” 任何建议将不胜感激

【问题讨论】:

  • 你能告诉我'which python'和'python --version'的输出吗
  • 我在google colab中运行了上面的代码。

标签: python google-colaboratory libtorrent


【解决方案1】:

将这两行粘贴到第一行之前。

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

【讨论】:

  • 非常感谢。真的行。我欠你的。再次,谢谢你。这将帮助很多人。
  • 为什么“错误:数据科学 0.10.6 有要求 folium==0.2.1,但您将有不兼容的 folium 0.8.3”显示?
  • 您能否解释一下为什么要添加这些额外的行?
  • 非常感谢
【解决方案2】:
!python -m pip install lbry-libtorrent
!apt install python3-libtorrent
 
import libtorrent as lt
 
ses = lt.session()
ses.listen_on(6881, 6891)
downloads = []

不需要 ;) !python -m pip install --upgrade pip setuptools wheel

【讨论】:

  • 排除!apt install python3-libtorrent这一行,剩下的就完成了。
【解决方案3】:
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.
Collecting pip
  Downloading https://files.pythonhosted.org/packages/fe/ef/60d7ba03b5c442309ef42e7d69959f73aacccd0d86008362a681c4698e83/pip-21.0.1-py3-none-any.whl (1.5MB)
     |████████████████████████████████| 1.5MB 6.1MB/s 
Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/70/06/849cc805ac6332210083f2114a95b22ee252ce81ed4e1be4f1d2b87c9108/setuptools-54.0.0-py3-none-any.whl (784kB)
     |████████████████████████████████| 788kB 40.8MB/s 
Requirement already up-to-date: wheel in /usr/local/lib/python3.7/dist-packages (0.36.2)
***`**ERROR: datascience 0.10.6 has requirement folium==0.2.1, but you'll have folium 0.8.3 which is incompatible.**`***
Installing collected packages: pip, setuptools
  Found existing installation: pip 19.3.1
    Uninstalling pip-19.3.1:
      Successfully uninstalled pip-19.3.1
  Found existing installation: setuptools 53.0.0
    Uninstalling setuptools-53.0.0:
      Successfully uninstalled setuptools-53.0.0
Successfully installed pip-21.0.1 setuptools-54.0.0
Collecting lbry-libtorrent
  Downloading lbry_libtorrent-1.2.4-py3-none-any.whl (2.4 MB)
     |████████████████████████████████| 2.4 MB 4.6 MB/s 
Installing collected packages: lbry-libtorrent
Successfully installed lbry-libtorrent-1.2.4

【讨论】:

猜你喜欢
  • 2019-03-28
  • 2022-01-07
  • 2017-12-14
  • 2020-12-10
  • 2021-09-02
  • 2020-10-10
  • 2022-01-06
  • 2021-09-10
相关资源
最近更新 更多