安装python3.11.7没有得到名为'_ssl'的模块

问题描述 投票:0回答:1

这是服务器操作系统版本

[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

我尝试安装 python 3.11.7 但失败了

no module named '_ssl'

所以我安装了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

我已经安装了openssl,然后像往常一样安装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 下的各个位置,与 Python 类似。

例如,通常OpenSSL默认安装在/usr/local/openssl中,并包含以下五个文件夹:bin、include、lib、share、ssl。然而,它似乎分散在以下位置:/usr/bin、/usr/include、/usr/lib64,从上面的 whereis 命令的结果也可以看到。

当我直接输入openssl版本并得到正确的版本号时,尝试直接安装python3.11.7总是告诉我SSL安装不正确。但是,我似乎无法使用 --with-openssl 来配置它。

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”的文件夹。我尝试使用
./configure --with-openssl=/usr/lib64/openssl/openssl11 --enable-optimizations
指定Python的库文件,但失败了。安装后SSL仍然无法使用。

这给我带来了很大的不便。现在我无法删除已安装的文件,也无法使用通常的方法配置我的 SSL。有人可以帮助我吗?

python linux ssl openssl centos
1个回答
0
投票

只需忽略现有的openssl,使用--prefix重新安装openssl以强制指定路径,然后也使用--prefix进行python安装。之后,将 python 根路径放入

PATH
中的
/etc/profile
。然后它解决了我的问题,现有的旧应用程序仍然运行良好。它以一种丑陋的方式工作......但它有效。

© www.soinside.com 2019 - 2024. All rights reserved.