在CentOS上使用pip安装软件包时出现问题(SSLError)

0 投票
1 回答
32 浏览
提问于 2025-04-14 16:32

我正在使用 CentOS 7.6.1810 这个系统。

我已经下载了 Python 所需的一些依赖项。

yum install openssl-devel bzip2-devel libffi-devel
yum groupinstall "Development Tools"

然后我下载了 Python 3.10.9。

sudo wget https://www.python.org/ftp/python/3.10.9/Python-3.10.9.tgz

解压后,我尝试进行安装步骤。

./configure --enable-optimizations
sudo make altinstall

安装步骤完成得有点快,我觉得有点可疑,当我尝试使用 pip 时,出现了以下错误。

Package    Version
---------- -------
pip        22.3.1
setuptools 65.5.0
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
WARNING: There was an error checking the latest version of pip.

我以为下载 openssl 这个依赖项可以解决这个问题。

有没有人知道我遇到的问题是什么,或者我该如何排查呢?

1 个回答

2

如果我按照你问题中提到的步骤来操作,在构建Python的时候我会看到这个错误:

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

这就是我在评论中提到的建议。你需要安装一个更新版本的openssl库,这样才能让Python支持ssl。

另外,你也可以考虑使用podman(或者docker)来运行一个容器化的Python,这样就能得到一个更新的版本,而不需要自己去构建。

撰写回答