【问题标题】:AttributeError: module 'enum' has no attribute 'IntFlag' in PycharmAttributeError:模块“枚举”在 Pycharm 中没有属性“IntFlag”
【发布时间】:2018-11-24 11:04:02
【问题描述】:

我已经阅读并尝试了这里的每个 cmets:Why Python 3.6.1 throws AttributeError: module 'enum' has no attribute 'IntFlag'? 但仍然没有帮助。

我使用的是 Pycharm Pycharm 2018.3 社区版,我的 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'

希望得到帮助。

【问题讨论】:

  • 你在某处有一个名为enum.py 的文件吗?

标签: python pycharm


【解决方案1】:

我在 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 支持后一切正常。

【讨论】:

  • 对我也有帮助!
  • PyCharm CE(与 OP 相同)不支持 Google App Engine,因此此选项在这种情况下不起作用。
猜你喜欢
  • 2019-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-24
  • 2021-10-04
  • 2018-05-08
  • 1970-01-01
相关资源
最近更新 更多