【发布时间】:2013-09-06 20:41:20
【问题描述】:
我正在尝试在即将到来的项目中使用线程,但我无法让它工作。我已经尝试在http://www.tutorialspoint.com/python/python_multithreading.htm 上运行第二个示例,我想这是工作代码,但我得到了错误...
Traceback (most recent call last):
File "C:/Python27/threads/threading.py", line 3, in <module>
import threading2
File "C:\Python27\lib\site-packages\threading2\__init__.py", line 49, in <module>
from threading import _active,_DummyThread
File "C:\Python27\threads\threading.py", line 8, in <module>
class myThread (threading2.Thread):
AttributeError: 'module' object has no attribute 'Thread'
怎么了?似乎没有名为 threading 的模块。我到处找它。有谁知道我在哪里可以找到这个模块以及如何安装它?
【问题讨论】:
-
附带说明,我不确定将 Python 2.4 称为“新”的教程是否是最好的起点……
-
您是否将自己的代码放入
C:\Python27中?这不是一个好主意。 -
threading2?以前从未听说过。 -
@user2357112:快速 PyPI 搜索 turns it up。显然是更厉害了。 :)
-
我不知道为什么在标准库
threading模块中会有任何对它的引用。看起来可能存在某种循环导入错误。编辑:那不是标准库threading模块。将代码放在 Python 安装文件夹中并将其命名为与标准库模块相同的名称都是不好的想法。
标签: python multithreading python-2.7 installation