Ubuntu20 安装 pip2
环境:ubuntu20, python2.7.18
1、配置 pip.conf(如果网络 ok,这一步省略)
root@myserver:~# cat /etc/pip.conf
# BEGIN ANSIBLE MANAGED BLOCK
[global]
# END ANSIBLE MANAGED BLOCK
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
2、下载 pip-get
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
3、如果需要代理,使用下面的 HTTPS_PROXY/https_proxy
export HTTPS_PROXY=http://192.168.1.1:3128
export https_proxy=http://192.168.1.1:3128
不要使用
export HTTPS_PROXY=https://192.168.1.1:3128
export https_proxy=https://192.168.1.1:3128
4、安装 pip2
root@myserver:~# python2 get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pip<21.0
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/27/79/8a850fe3496446ff0d584327ae44e7500daf6764ca1a382d2d02789accf7/pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
|################################| 1.5 MB 5.3 MB/s
Collecting setuptools<45
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e1/b7/182161210a13158cd3ccc41ee19aadef54496b74f2817cc147006ec932b4/setuptools-44.1.1-py2.py3-none-any.whl (583 kB)
|################################| 583 kB 3.0 MB/s
Collecting wheel
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-20.3.4 setuptools-44.1.1 wheel-0.36.2
参考文章
https://stackoverflow.com/questions/56628194/sslerror-installing-with-pip