You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS7.9安装Python3.11.7遇_ssl模块缺失问题求助

问题:CentOS 7.9安装Python 3.11.7时_ssl模块缺失无法编译

服务器环境

[root@hdp1 bin]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.9.2009 (Core)
Release:    7.9.2009
Codename:   Core

安装OpenSSL 1.1.1w后,相关信息:

[root@hdp1 bin]# openssl version
OpenSSL 1.1.1w  11 Sep 2023 (Library: OpenSSL 1.1.1k  FIPS 25 Mar 2021)
[root@hdp1 bin]# whereis openssl
openssl: /usr/bin/openssl /usr/lib64/openssl /usr/local/bin/openssl /usr/include/openssl /usr/share/man/man1/openssl.1ssl.gz
[root@hdp1 bin]# which openssl
/usr/local/bin/openssl

问题描述

尝试安装Python 3.11.7时失败,报错no module named '_ssl'。安装OpenSSL 1.1.1w后,沿用以往有效步骤重新编译Python,仍然无法解决问题。

以往有效安装步骤

tar -zxvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
./config –prefix=/usr/local/openssl shared zlib 
make && make install

tar -zxvf Python-3.11.7.tgz
cd Python-3.11.7
./configure --with-openssl=/usr/local/openssl
make && make altinstall

当前异常情况

本次在新服务器上安装时,OpenSSL未按指定路径/usr/local/openssl安装,而是分散到/usr/bin、/usr/include、/usr/lib64等系统目录下,与Python的分散安装方式类似。

直接执行openssl version能显示正确的1.1.1w版本,但编译Python时仍提示SSL模块无法构建,报错如下:

The necessary bits to build these optional modules were not found:
_hashlib              _ssl                  _tkinter           
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer

已尝试的无效操作

发现/usr/lib64/openssl下有openssl11目录,尝试通过以下命令配置Python:

./configure --with-openssl=/usr/lib64/openssl/openssl11 --enable-optimizations

编译安装完成后,SSL模块仍然无法使用。目前无法删除已安装的OpenSSL文件,也无法通过常规方法完成Python的SSL配置,寻求解决方案。

内容的提问来源于stack exchange,提问作者william

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 09:35:24