Python解决SSL不可用问题

博客指出Python 3.7之后版本依赖OpenSSL 1.1或1.0.2之后版本。以安装Python 3.10为例,若系统自带OpenSSL版本低则需更新。介绍了查看Linux系统OpenSSL版本信息的方法,还给出更新OpenSSL版本及重新编译Python的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、问题描述:

报错概述:

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
## 警告:pip配置了需要TLS/SSL的位置,但是Python中的SSL模块不可用。

在这里插入图片描述

二、解决方案:

首先要明白python版本需要和openssl的版本需要相对匹配的,在Python3.7之后的版本,依赖的openssl,必须要是1.1或者1.0.2之后的版本,或者安装了2.6.4之后的libressl,linux自带的openssl版本过低

1、查看liunx系统的openssl版本信息:
openssl version

在这里插入图片描述
如图所示:小编的买的liunx服务器自带的openssl版本为1.1.1a ,然而对于小编来说,要安装python3.10的版本来说,openssl的版本太低了,因此需要更新openssl的版本才能满足要求;

2、更新openssl版本:
(1)安装相关依赖
yum install gcc libffi-devel zlib* openssl-devel

在这里插入图片描述

(2)官网下载openssl版本
wget https://www.openssl.org/source/openssl-3.0.1.tar.gz
(3)解压openssl
tar -zxvf openssl-3.0.1.tar.gz
(4)编译openssl
# 进入解压后的文件目录,切记一定要进入该目录才能继续执行后续命令
 cd openssl-3.0.1

其中--prefix是指定安装目录的,shared zlib库是在安装时寻找zlib库依赖的

# 配置(configure)
./config --prefix=/usr/local/openssl

在这里插入图片描述

# 编译
make 
# 安装
make install

最后重新查看openssl版本

openssl version

在这里插入图片描述

2、重新编译python
(1)官网下载python
wget https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tgz
(2)解压python
tar -xzvf Python-3.10.5.tgz 
(3)编译 python
./configure --prefix=/usr/local/python3
make
make install
(4)建立软连接
ln -s /usr/local/python3/bin/python3.10.1 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.10 /usr/bin/pip3
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值