解决python3.7报错Can‘t connect to HTTPS URL because the SSL module is not available

文章目录

      • 报错现象
      • 原因
      • 解决

报错现象

在使用pip安装时报错Can’t connect to HTTPS URL because the SSL module is not available

原因

openssl依赖版本过低

解决

上openssl官网下载1.0.2或者1.1之后的openssl包,编译安装。我选择的是1.0.2r

wget http://www.openssl.org/source/openssl-1.0.2r.tar.gz
tar zxvf openssl-1.0.2r.tar.gz
cd openssl-1.0.2r/
./config --prefix=/opt/openssl1.0.2r --openssldir=/opt/openssl1.0.2r/openssl no-zlib
make && make install
echo "/opt/openssl1.0.2r/lib" >> /etc/ld.so.conf

修改python3.7源码包目录中的Modules/Setup参数,修改ssl目录并将下面三行注释去掉

vim /root/Python-3.7.7/Modules/Setup

解决python3.7报错Can‘t connect to HTTPS URL because the SSL module is not available_第1张图片
重新编译python3

cd /root/Python-3.7.7
make && make install

验证pip

pip3 list
Package    Version
---------- -------
pip        19.2.3 
psutil     2.0.0  
setuptools 41.2.0 
XlsxWriter 1.3.2  
WARNING: You are using pip version 19.2.3, however version 20.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

你可能感兴趣的:(Python)