背景
python3.10,pip3下载模块失败,报错:# Caused by SSLError(“Can‘t connect to HTTPS URL because the SSL module is not available.“
原因
centos7.8默认可安装的openssl版本为1.1.0,python3.10支持的openssl版本为1.1.1以上
解决
- 下载支持的openssl包,编译安装
wget https://www.openssl.org/source/openssl-1.1.1q.tar.gz
tar -zxvf openssl-1.1.1q.tar.gz
cd openssl-1.1.1q
./Configure --prefix=/usr/local/openssl #指定安装目录
#这里不会配置成功,会有信息提示:
# If in doubt, on Unix-ish systems use ‘./config ‘.
将命令换为./config --prefix=/usr/local/openssl
make -j && make install
- python编译安装
#编译时加上--with-openssl --with-openssl-rpath两个参数即可
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl --with-openssl-rpath=auto