结论先行:
修改
requirements.txt
中MarkuoSafe==1.0
为MarkuoSafe==1.1.1
后,重新安装requirements.txt
即可。
错误输出:
Collecting MarkupSafe==1.0
Using cached https://mirrors.aliyun.com/pypi/packages/4d/de/32d741db316d8fdb7680822dsfsafas33sdfasfd37001erfsfe/MarkupSafe-1.0.tar.gz (14 kB)
ERROR: Command errored out with exit status 1:
command: /home/reidlv/flaskspace/py3.6/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ykm44ayc/MarkupSafe/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ykm44ayc/MarkupSafe/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-a6l_b7k5
cwd: /tmp/pip-install-ykm44ayc/MarkupSafe/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-ykm44ayc/MarkupSafe/setup.py", line 6, in <module>
from setuptools import setup, Extension, Feature
ImportError: cannot import name 'Feature'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
错误环境:
- virtualenv 生成的 python3.6.11环境。
setuptools==49.2.0
MarkuoSafe==1.0
pip install -r requirements.txt
中执行到pip install MarkuoSafe==1.0
错误原因:
MarkupSafe tries to import setuptools.Feature which results in an error as it's deprecated.
1
解决方案:
This had been fixed since 0.19, but for some reason a revert to that fix made it into 1.0 (d2001bb), then was removed again in 1.1. Unless you really need 1.0 for some reason, I'd advise just upgrading to 1.1.1, there shouldn't be any compatibility issues.
2
总结:
因MarkupSafe==1.0 版本较低, 其引用
Feature
的方式from setuptools import Feature
在新版本的setuptools
包中已被弃用,
所以导致了上文出现的bug。
那解决思路就清晰了,如下思路取一即可。
- 升级
MarkupSafe==1.1.1
- 降级
setuptools==45.2.0