作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在运行使用“导入枚举”的 Python 文件时遇到问题,给了我这个问题:
Traceback (most recent call last):
File "lowest_common_ancestor.py", line 4, in <module>
from test_framework import generic_test, test_utils
File "/Users/linh/Documents/EPIJudge/epi_judge_python/test_framework/generic_test.py", line 6, in <module>
from test_framework.generic_test_handler import GenericTestHandler
File "/Users/linh/Documents/EPIJudge/epi_judge_python/test_framework/generic_test_handler.py", line 5, in <module>
from test_framework.binary_tree_utils import assert_equal_binary_trees, is_object_tree_type
File "/Users/linh/Documents/EPIJudge/epi_judge_python/test_framework/binary_tree_utils.py", line 5, in <module>
from test_framework.test_failure import TestFailure, PropertyName
File "/Users/linh/Documents/EPIJudge/epi_judge_python/test_framework/test_failure.py", line 2, in <module>
from enum import Enum, auto
ImportError: cannot import name 'auto'
我知道我有Python 2.7,并且“导入枚举”仅存在于Python 3中,但是我在如何创建两个同时拥有Python 2.7和Python 3的不同环境时遇到了麻烦。如何去做呢?在 Mac Unix 终端上,我对此也不是很熟悉。
最佳答案
auto
直到 Python 3.6 才出现,并且不在 enum34
向后移植中。如果您想要 2/3 兼容代码,您需要使用 aenum
1。
我没有任何使用 Mac Unix 终端的经验。
<小时/>1 披露:我是 Python stdlib Enum
的作者,enum34
backport ,以及 Advanced Enumeration (aenum
)图书馆。
关于python - 导入枚举文件与 Python 2.7 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50092876/
我是一名优秀的程序员,十分优秀!