开发者

python window threading

I am importing in windows:

from threading import Thread   

It gives me error as:

cannot import name Th开发者_开发技巧read

Can anyone resolve this issue?


Maybe the python file in named threading.py? If yes, try to change the name.


modify your code to look like this:

import threading
print "threading imported from", threading.__file__

If the first line fails it means your installation is somehow misconfigured or is missing this library. If the first line succeeds, the second should tell you what actual file is being loaded. Presumably this will show that it's importing the wrong file, and you can use that information to further debug the problem.

My guess is, you have a file named "threading.py" in your current directory, but that's just a guess based on insufficient information.


Works fine here:

C:\Program Files (x86)\Console2>python
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from threading import Thread
>>>

Which version are you using?


If memory serves me right, in older versions of python (2.4?) you had to do this:

import threading
foo = threading.Thread()  # or
class Foo(threading.Thread):
    pass

but you could not from threading import Thread

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜