[英]It gives me ImportError when I import `from concurrent.futures import ThreadPoolExecutor`. Does anyone know why?
I get ImportError when I try to import: 尝试导入时出现ImportError:
from concurrent.futures import ThreadPoolExecutor
ERROR: 错误:
Traceback (most recent call last):
File "queue.py", line 4, in <module>
from concurrent.futures import ThreadPoolExecutor
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/__init__.py", line 48, in __getattr__
from .thread import ThreadPoolExecutor as te
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py", line 11, in <module>
import queue
File "/Users/tigranfahradyan/Desktop/python3/learning/queue.py", line 4, in <module>
from concurrent.futures import ThreadPoolExecutor
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/__init__.py", line 48, in __getattr__
from .thread import ThreadPoolExecutor as te
ImportError: cannot import name 'ThreadPoolExecutor' from 'concurrent.futures.thread' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py)
It seems that something is wrong with queue
module. queue
模块似乎出了点问题。 Can anyone help to figure this out? 谁能帮忙解决这个问题?
You've got a case of dependency confusion there. 您在那里遇到了依赖混乱的情况。 Check the stack-trace.
检查堆栈跟踪。 See that line where it's trying to import
queue
and that resolves to /Users/.../queue.py
. 在尝试导入
queue
那一行中看到该行,该行解析为/Users/.../queue.py
。 I'm guessing that's some file you wrote. 我猜那是你写的一些文件。 The python import mechanism is confused between that
queue.py
and the queue.py
of concurrent.futures
. 蟒蛇进口机制是混淆之间
queue.py
和queue.py
的concurrent.futures
。
Try renaming your queue.py
file to something else. 尝试将您的
queue.py
文件重命名为其他名称。
Can you share your Queue file. 您可以共享您的队列文件吗? It should work if we import from concurrent.futures import ThreadPoolExecutor in python 3.2 or later version.
如果我们从并发导入,它应该可以工作.futures在python 3.2或更高版本中导入ThreadPoolExecutor 。 It would be very happy to look into it if you could share snippet of queue.py file to investigate more.
如果您可以共享queue.py文件的片段进行更多研究,非常乐意进行调查。 Try changing queue.py name and run, if not works, share your snippet, i will look into into for you.
尝试更改queue.py名称并运行,如果不起作用,请分享您的代码段,我会为您调查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.