我正尝试在Centos 7上的Python 2.7.5上升级pip到最新版本。
# python -m pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/9e/24/bc928987f35dd0167f21b13a1777c21b9c5917c9894cff93f1c1a6cb8f3b/pip-21.0.tar.gz
Complete output from command python setup.py egg_info:
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-eMN0xl/pip/setup.py", line 85, in <module>
python_requires='>=3.6',
File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 269, in __init__
_Distribution.__init__(self,attrs)
File "/usr/lib64/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 302, in finalize_options
ep.load()(self, ep.name, value)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2302, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2312, in resolve
raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'check_specifier'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-eMN0xl/pip/
我也尝试升级设置工具,但是失败了。
# python -m pip install --upgrade setuptools
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/84/48/5c99d8770fd0a9eb0f82654c3294aad6d0ba9f8600638c2e2ad74f2c5d52/setuptools-52.0.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "setuptools/__init__.py", line 16, in <module>
import setuptools.version
File "setuptools/version.py", line 1, in <module>
import pkg_resources
File "pkg_resources/__init__.py", line 1367
raise SyntaxError(e) from e
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ohx4SA/setuptools/
上周五这个还能正常工作,然而从本周开始似乎就不行了。请问你能提供一些建议吗?
pip install --upgrade pip==20.3
命令进行安装。pip 21.0
及更高版本不再支持 Python 2。请参阅 https://pip.pypa.io/en/stable/development/release-process/#python-2-support。 - snakecharmerb