错误:找不到满足要求 pip 的版本(来自版本:无)

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

我在使用 Python 版本 3.10.0 时,在 CentOS 上遇到 pip 安装问题。我尝试通过执行

get-pip.py
脚本来安装 pip。然而,在这个过程中,我遇到了与SSL模块相关的错误,导致安装无法成功完成。

为了继续安装,我使用以下命令来检索

get-pip.py
文件:

wget https://bootstrap.pypa.io/pip/get-pip.py

运行命令 python

get-pip.py
时,我收到以下错误:

[root@env lak]# python get-pip.py
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
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
ERROR: Could not find a version that satisfies the requirement pip (from versions: none)
ERROR: No matching distribution found for pip
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

如何解决此问题并在 python 3.10 上安装 pip。

python python-3.x ssl pip get-pip.py
1个回答
0
投票

您可能缺少系统 SSL 库,或者 Python 安装是在没有 SSL 支持的情况下构建的。

您可以通过运行

openssl version
python -c "import ssl; print(ssl.OPENSSL_VERSION)"
来判断是哪种情况。

如果您只是缺少 SSL 库,修复方法就像

yum install openssl
一样简单。

如果您的 Python 安装没有 SSL,那么您可能需要 从源代码构建 Python 。确保启用该标志

./configure --with-ssl

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