环境:python2.7
原因:
因为不再维护Python 2.7。pip 21.0将于2021年1月停止对Python 2.7的支持。pip 21.0将删除对此功能的支持。解决此问题并继续使用不受支持的Python 2.7,不应升级到最新的pip版本,而应升级到<21的版本
报错内容:
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==21.0', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
解决办法:
yum remove python-pip
cd /usr/local/src
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
pip -V
python2.7想升级pip的话,注意版本要小于21.0
pip install --upgrade "pip < 21.0"