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

$ 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.

原文地址:https://www.cnblogs.com/timssd/p/4703551.html