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
相关推荐
ZhengEnCi4 小时前
08c. 检索算法与策略-混合检索
后端·python·算法
明月_清风10 小时前
Python 内存手术刀:sys.getrefcount 与引用计数的生死时速
后端·python
明月_清风10 小时前
Python 消失的内存:为什么 list=[] 是新手最容易踩的“毒苹果”?
后端·python
Flittly1 天前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(3)TodoWrite (待办写入)
python·agent
千寻girling1 天前
一份不可多得的 《 Django 》 零基础入门教程
后端·python·面试
databook1 天前
探索视觉的边界:用 Manim 重现有趣的知觉错觉
python·动效
明月_清风1 天前
Python 性能微观世界:列表推导式 vs for 循环
后端·python
明月_清风1 天前
Python 性能翻身仗:从 O(n) 到 O(1) 的工程实践
后端·python
helloweilei2 天前
python 抽象基类
python
用户8356290780512 天前
Python 实现 PPT 转 HTML
后端·python