AttributeError:模块“枚举”在Pycharm中没有属性“ IntFlag”

时间:2018-11-24 11:04:03

标签: python pycharm

我已在这里阅读并尝试了所有评论:Why Python 3.6.1 throws AttributeError: module 'enum' has no attribute 'IntFlag'?,但仍然没有帮助。

我正在使用Pycharm Pycharm 2018.3 Community Edition,而我的Python版本是3.7

每次尝试为Pycharm设置解释器时,都会出现此错误:

Error in sitecustomize; 
set PYTHONVERBOSE for traceback: AttributeError: module 'enum' has no attribute 'IntFlag'
Traceback (most recent call last):   File "/Applications/PyCharm CE.app/Contents/helpers/packaging_tool.py", line 2, in <module>
import traceback   File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/traceback.py", line 5, in <module>
import linecache   File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/linecache.py", line 11, in <module>
import tokenize   File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tokenize.py", line 33, in <module>
import re   File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py", line 143, in <module>
class RegexFlag(enum.IntFlag): AttributeError: module 'enum' has no attribute 'IntFlag'

希望获得帮助。

1 个答案:

答案 0 :(得分:2)

我在PyCharm中遇到了相同的问题,一个简单的程序没有运行。在PyCharm之外,我没有任何问题。比较python -v之后,发生了什么

lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'

a successful run used lib/python3.6/__pycache__/re.cpython-36.pyc' and then 
/lib/python3.6/__pycache__/enum.cpython-36.pyc'

while the failed run included: lib/python3.6/__pycache__/re.cpython-36.pyc'
and then: google_appengine/lib/grpcio-1.9.1/enum/__pycache__/__init__.cpython-36.pyc 

在PyCharm中禁用App Engine支持后,一切正常。