pip2 安装
yum install -y epel-release
yum install -y python-pip
根据这条命令升级pip2成功后报错
pip install --upgrade "pip < 21.0"
报错如下,这是因为Python 2.7已于2020年1月1日到期,请停止使用。请升级您的Python,因为不再维护Python 2.7。pip 21.0将于2021年1月停止对Python 2.7的支持。pip 21.0将删除对此功能的支持。
[root@test102 ~]# pip --version Traceback (most recent call last): File "/usr/bin/pip", line 9, inload_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}") ^ SyntaxError: invalid syntax
参考:https://pip.pypa.io/en/latest/development/release-process/#python-2-support
解决办法:
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py python2 get-pip.py