【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步骤)

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

狮子王量化

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值