Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python threading module import failure

I'm trying to import the threading module, however, i just seem to get errors for no good reason. Here is my code:

import threading

class TheThread ( threading.Thread ):
    def run ( self ):
        print 'Insert some thread stuff here.'
        print 'I\'ll be executed...yeah....'
        print 'There\'s not much to it.'

TheThread.Start()

And the errors:

Traceback (most recent call last):
  File "threading.py", line 1, in <module>
    import threading
  File "C:\Users\Trent\Documents\Scripting\Python\Threading\threading.py", line
3, in <module>
    class TheThread ( threading.Thread ):
AttributeError: 'module' object has no attribute 'Thread'
Press any key to continue . . .

Python stats:

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win 32

like image 975
Trent Avatar asked Nov 09 '11 08:11

Trent


1 Answers

i think that all you need is just to rename the name of your working file, because your file name is the same as module name:

threading.py

or you have wrong threading.py file in your working directory

like image 140
FoRever_Zambia Avatar answered Oct 10 '22 08:10

FoRever_Zambia