Python解决SSL不可用问题

参考:https://blog.csdn.net/weixin_44894162/article/details/126342591

一、问题描述:

报错概述:

复制代码
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.0.2 ,然而对于小编来说,要安装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

复制代码
./configure --prefix=/usr/local/python3

make

make install
相关推荐
copyer_xyf22 分钟前
LangChain 调用 LLM
后端·python·agent
copyer_xyf31 分钟前
Prompt 组织管理
后端·python·agent
asdfg125896340 分钟前
JavaBean是什么?怎么理解?有什么用途?
java·开发语言
dsyyyyy11011 小时前
JavaScript变量
开发语言·javascript·ecmascript
shimly1234561 小时前
python3 uvicorn 是啥?
python
z落落2 小时前
C#WinForm 窗体切换与窗体传值(登录跳转案例)+WinForm 窗体传值(从上往下传、从下往上传)
开发语言·windows·c#
CTA量化套保2 小时前
期货量化程序 time.sleep 卡死:天勤单线程与 deadline 替代
python·区块链
allway22 小时前
How to Echo Multiline to a File in Bash [3 Methods]
开发语言·chrome·bash
weixin_462446232 小时前
手把手教你用 Bash 脚本自动更新 /etc/hosts —— 自动绑定网卡 IP 与节点名
开发语言·tcp/ip·bash
一个梦醒了2 小时前
安装git bash选项推荐
开发语言·git·bash