admin管理员组文章数量:1650774
setuptools ImportError: cannot import name 'Feature'
- 结论先行:
- 错误输出:
- 错误环境:
- 错误原因:
- 解决方案:
- 总结:
结论先行:
修改
requirements.txt
中MarkuoSafe==1.0
为MarkuoSafe==1.1.1
后,重新安装requirements.txt
即可。
错误输出:
Collecting MarkupSafe==1.0
Using cached https://mirrors.aliyun/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
Fixed an error with MarkupSafe installation #234 ↩︎
Markupsafe breaks with latest version of setuptools #116 ↩︎
本文标签: ImportErrorPythonimportsetuptoolsfeature
版权声明:本文标题:PYTHON——ImportError: cannot import name ‘Feature‘ from setuptools 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1729533447a1205107.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论