本文介绍了AttributeError: 模块“enum"在 Pycharm 中没有属性“IntFlag"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读并尝试了这里的所有评论:为什么 Python 3.6.1 抛出 AttributeError: module 'enum' has no attribute 'IntFlag'? 但仍然没有帮助.

I have read and tried every comments here: Why Python 3.6.1 throws AttributeError: module 'enum' has no attribute 'IntFlag'? but still, it is of no help.

我使用的是 Pycharm Pycharm 2018.3 社区版,我的 Python 版本是 3.7

I am using Pycharm Pycharm 2018.3 Community Edition and my Python version is 3.7

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

I have this error everytime I try to setup an interpreter for 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'

希望得到帮助.

推荐答案

我在 PyCharm 中遇到了同样的问题,一个简单的程序没有运行.在 PyCharm 之外,我没有任何问题.比较 python -v 这就是发生的事情

I had the same problem inside PyCharm a simple program did not run. outside PyCharm I had no issues. after comparing python -v this is what happened

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 支持后一切正常.

after disabling App Engine Support in PyCharm all worked fine.

这篇关于AttributeError: 模块“enum"在 Pycharm 中没有属性“IntFlag"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 10:36