【发布时间】:2020-06-06 16:28:59
【问题描述】:
今天我想在 Ubuntu 16.04 上设置 CTFd,但我遇到了一个奇怪的 ImportError。阅读ImportError: cannot import name 'IntEnum' 并尝试了所有我能得到的解决方案,我发现错误仍未解决。
root@iZbp16wvcnnjq61mspee7aZ:/var/www/CTFd# pip install enum34 //As you can see, I have tried to install enum34 :(
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Requirement already satisfied: enum34 in /usr/local/lib/python2.7/dist-packages (1.1.8)
root@iZbp16wvcnnjq61mspee7aZ:/var/www/CTFd# python serve.py
Traceback (most recent call last):
File "serve.py", line 11, in <module>
app = create_app()
File "/var/www/CTFd/CTFd/__init__.py", line 223, in create_app
from CTFd.api import api
File "/var/www/CTFd/CTFd/api/__init__.py", line 2, in <module>
from flask_restplus import Api
File "/usr/local/lib/python2.7/dist-packages/flask_restplus/__init__.py", line 4, in <module>
from . import fields, reqparse, apidoc, inputs, cors
File "/usr/local/lib/python2.7/dist-packages/flask_restplus/fields.py", line 20, in <module>
from .errors import RestError
File "/usr/local/lib/python2.7/dist-packages/flask_restplus/errors.py", line 8, in <module>
from ._http import HTTPStatus
File "/usr/local/lib/python2.7/dist-packages/flask_restplus/_http.py", line 6, in <module>
from enum import IntEnum
ImportError: cannot import name IntEnum // THE PROBLEM!
【问题讨论】:
-
您使用的是 Python 2.7,它没有枚举,并且正如消息告诉您的那样,它是 EoL。
-
检查您是否有
pip3和python3使用 Python 3 而不是Python 2 -
您使用的是哪个版本的
flask_restplus?你能更新到最新的试试吗? -
那么...你能告诉我如何避免这个问题吗?我应该输入一些其他代码而不是“python serve.py”来使用Python 3运行它吗?谢谢,但请告诉我更多,抱歉浪费您的时间。
-
@jonrsharpe:Python 2.7 没有
enum,是的,但是 OP 正在使用enum34来弥补它。 (暂时中断,但在 1.1.9 中已修复。)
标签: python ubuntu-16.04 lib