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

1 投票
1 回答
45 浏览
提问于 2025-04-12 14:27

我在CentOS上安装pip时遇到了问题,使用的是Python 3.10.0版本。我尝试通过运行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呢?

1 个回答

2

你可能缺少一个系统的SSL库,或者你的Python安装时没有支持SSL。

你可以通过运行 openssl versionpython -c "import ssl; print(ssl.OPENSSL_VERSION)" 来判断是哪种情况。

如果只是缺少SSL库,解决方法可能很简单,只需要运行 yum install openssl

如果你的Python安装没有SSL支持,那你可能需要从源代码编译Python。确保你在配置时启用 ./configure --with-ssl 这个选项。

撰写回答