【发布时间】:2018-05-19 19:17:19
【问题描述】:
在我的终端中,我想用 asyncio 测试一些东西。这是我所做的:
$ python3.6
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
这引发了如下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/__init__.py", line 42, in <module>
tasks.__all__ +
AttributeError: module 'asyncio.tasks' has no attribute '__all__'
为什么会引发此错误,我该如何解决? (我以同样的方式检查了我的 python 3.5 解释器并且没有出错,所以可能是库损坏了?)
我用-v开关运行Python,在提示符下运行import asyncio后产生的输出相当大,所以它在this GitHub gist中可用。
【问题讨论】:
-
显示完整的 Python 版本
-
python 3.6.2.我会补充的。
-
尝试 brew upgrade python3
-
那是……出乎意料。看起来您可能有一个本地
asyncio.tasks模块隐藏内置版本?您是否有可能有一个asyncio目录其中没有__init__.py文件,但有一个tasks.py文件? -
不,我绝对不。 @GregEremeev 现在就这样做。
标签: python python-import python-3.6 importerror python-asyncio