【Linux】pip is configured with locations that require TLS/SSL, however the ssl module in Python is no

1.问题描述

在linux中安装完 Python.7 后,使用 pip3(Python3.x自带)安装模块时,出现以下异常,导致安装失败:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

2.问题原因

当前行系统没有 openssl 或者版本比较低,一般 python3.7 需要的openssl的版本为1.0.2或者1.1.x。需要对 openssl 进行升级,并重新编译 python3.7.0。

3.解决方法

下载openssl
地址:openssl-1.1.1a.tar.gz

创建安装目录
mkdir -p usr/local/openssl

解压
tar -zxvf openssl-1.1.1a.tar.gz

编译安装
cd openssl-1.1.1a
./config --prefix=/usr/local/openssl no-zlib #不需要zlib
make
make install

备份原配置
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl/ /usr/include/openssl.bak

新版配置
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

修改系统配置,写入openssl库文件的搜索路径
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf

使修改后的/etc/ld.so.conf生效 
ldconfig -v

重新安装python
cd Python-3.7.5
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
make
make instal

4.最后,成功解决问题,能够使用 pip3 安装模块

参考文章:【Python包】pip安装teradatasql时提示没有TLS/SSL模块(含安装Perl步骤)

猜你喜欢

转载自blog.csdn.net/CSDN_fzs/article/details/103220535