码迷,mamicode.com
首页 > 其他好文 > 详细

AttributeError: 'module' object has no attribute 'Thread'

时间:2015-08-05 06:25:57      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

$ python thread.py
starting at: 2015-08-05 00:24:24
Traceback (most recent call last):
  File "thread.py", line 28, in <module>
    main()
  File "thread.py", line 16, in main
    th = threading.Thread(target= test,args= (i,2))
AttributeError: ‘module‘ object has no attribute ‘Thread‘
Exception AttributeError: ‘_shutdown‘ in <module ‘threading‘ from ‘/home/tim/Desktop/sourceeeeeeeeeeeeeeee//threading.pyc‘> ignored

Check that you have not named your script threading.py

8 down vote accepted

I bet you have a local file named threading.py, and it‘s masking the system threading module.

You can verify this by printing threading.__file__:

import threading
print threading.__file__

to get the file path of the module that is being imported.

Rename it, or delete it, to fix this.

AttributeError: 'module' object has no attribute 'Thread'

标签:

原文地址:http://www.cnblogs.com/x113/p/4703551.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!