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
相关推荐
量化分析码农9 小时前
【Python量化趋势跟踪实战 01】均线多头排列就是趋势开始吗:过滤与确认
python
用户298698530149 小时前
Python 实战:把代码写入 Word 文档的两种实现方式
后端·python·api
小小张说故事9 小时前
Python 里 pickle 到底存了什么:拆开 __reduce__、__getstate__ 和那串能执行代码的字节码
python
瑞雪兆丰年兮9 小时前
JavaWeb-day10-SpringBootWeb案例
java·开发语言·javaweb·web
reasonsummer9 小时前
【教学类-150-03】20261108蝴蝶连连看html(一页2个版面、3个版面)
python·html
Elastic 中国社区官方博客9 小时前
更少的位数,相同的召回率:DiskBBQ 更保守的自动校准扫描
大数据·运维·开发语言·人工智能·elasticsearch·搜索引擎
用户019027581619 小时前
用 Polars 快速分析 A 股 K 线:比 pandas 更快的列式处理
python
用户0332126663679 小时前
使用 Python 轻松加密或解密 Excel 文档
python·excel
三雷科技9 小时前
第6章第4节:自定义分词器
开发语言·c#
Adellle10 小时前
设计模式指南 (Java 版) ㊁
java·开发语言·设计模式