【问题标题】:How do i install python3 threading module in linux ubuntu如何在 linux ubuntu 中安装 python3 线程模块
【发布时间】:2018-11-27 19:53:31
【问题描述】:

当我尝试在 python3 中安装线程模块时,会发生错误:

  Could not find a version that satisfies the requirement threading (from versions: )

找不到匹配的线程分布 我已经尝试过安装这些:

pip3 install threading
pip3 install thread
python3 -m pip install threading
python3 -m pip install thread
sudo apt-get install python3-threading
sudo apt-get install python3-thread

我已经尝试过这些。前四个发生了:

Could not find a version that satisfies the requirement thread (from versions: )
No matching distribution found for thread

最后两个

Reading package lists... Done
Building dependency tree
Reading state information... Done E: Unable to locate package python3-threading(or thread)
我能做些什么来安装那个模块。

【问题讨论】:

  • 这个需求文件来自哪里? threading 是标准库的一部分,不需要安装,只需import threading
  • 但是当我尝试导入出现的线程时:ModuleNotFoundError: No module named 'thread'
  • 通常这表明您有一个名为threading.py 的文件,因此如果您使用from threading import thread,它会尝试从该模块导入它。
  • 那是正确的。我很久以前就创建了。我被遗忘了。我删除了那个文件。在我尝试导入线程之后。那工作。不存在线程模块有 from threading import Thread 可能是我的错。谢谢。
  • 是的线程模块已被弃用

标签: linux python-3.x python-module


【解决方案1】:

如果你安装thread6,你将能够导入线程

【讨论】:

  • 预览答案有什么新的吗?
【解决方案2】:

你可以运行:

pip install thread6

pip 是 python 的包管理器,用于安装 python 包或模块。请注意,您的系统上可能也有 python2.x,并且可能会使用此命令调用 pip v2。为了安全起见,运行:

pip3 install thread6

【讨论】:

  • 谢谢。当“导入名称”不等于包名称时,始终搜索包名称。
猜你喜欢
  • 2018-07-21
  • 2016-03-20
  • 1970-01-01
  • 1970-01-01
  • 2021-02-04
  • 1970-01-01
  • 2021-02-22
  • 2014-05-23
  • 2021-10-17
相关资源
最近更新 更多