centos解决 pip is configured with locations that require TLS/SSL, however the ssl module in Python is

一、下载 openssl 编译安装

openssl 官方下载地址:https://www.openssl.org/source/

wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1d.tar.gz

解压

tar -zxvf OpenSSL_1_1_1d.tar.gz

二、编译安装

进入openssl-OpenSSL_1_1_1d

cd openssl-OpenSSL_1_1_1d

 

指定安装路径并编译

./config --prefix=/usr/local/openssl // 指定安装路径 make && make install

三、替换当前系统的旧版本 openssl 「先保存原来的」

mv /usr/bin/openssl /usr/bin/openssl.old mv /usr/lib64/openssl /usr/lib64/openssl.old mv /usr/lib64/libssl.so /usr/lib64/libssl.so.old ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl ln -s /usr/local/openssl/include/openssl /usr/include/openssl ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so echo /usr/local/openssl/lib >> /etc/ld.so.conf ldconfig -v // 建立动态链接

四、最后查看当前系统 openssl 版本

openssl version

五、重新编译Python3.7

进入解压后的Python目录

cd Python-3.7.1 ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl make make install ln -sf /usr/local/python3/bin/python3 /usr/bin/python3 ln -sf /usr/local/python3/bin/pip3 /usr/bin/pip3

六、查看是否安装成功

python3 -V pip3 -V