RHEL7安装openssl:解决the ssl module in Python is not available问题

我的系统是RHEL7,改了Centos的yum源,安装python3后发现ssl经常出问题,pip无法从网站下载第三方库,常出现以下这种类型的提示:

[root@localhost ~]# pip3 install virtualenv
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting virtualenv
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/

原因是所有openssl的版本为OpenSSL 1.0.1e-fips 11 Feb 2013,而python3.7需要的openssl的版本为1.0.2或者1.1.x,需要对openssl进行升级,并重新编译python3.7.6。

从https://www.openssl.org/source/openssl-1.1.1-pre8.tar.gz下载openssl-1.1.1-pre8.tar.gz以后,将压缩包解压后放入/usr/local/目录下。然后切换目录:

[root@linuxprobe 桌面]# cd /usr/local/openssl-1.1.1-pre8/

然后编译到/usr/目录下:

[root@linuxprobe openssl-1.1.1-pre8]# ./config --prefix=/usr/ no-zlib
Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1-pre8 (0x10101008L) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
***                                                                ***
***   If you want to report a building issue, please include the   ***
***   output from this command:                                    ***
***                                                                ***
***     perl configdata.pm --dump                                  ***
***                                                                ***
**********************************************************************

编译并安装:

[root@linuxprobe openssl-1.1.1-pre8]# make && make install

得益于我们选择的安装路径/usr/,很多配置全省了。现在查一下openssl的版本:

[root@linuxprobe lib]# openssl version
OpenSSL 1.1.1-pre8 (beta) 20 Jun 2018

成功。现在重新安装python3.7.6就行了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值