在我的Ubuntu 20.04
.我使用两个python
版本。其中一个是Python3.8.2,它随我的Ubuntu安装而来,另一个是Python3.7.5。我在系统默认版本旁边安装了Python3.7.5,使用update-替代品
。但是现在的问题是没有pip
命令在Python3.7.5
上工作。虽然pip
在这个(Python3.7.5
)安装中可用,但是在打印版本时,它显示了以下内容(使用命令pip 3.7-V
):
pip 19.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
但是每当我尝试使用安装包时,它总是显示标题中提到的错误。例如,在安装以下软件包时:
sudo pip3.7 install intel-tensorflow==1.15.2
将引发以下错误:
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting intel-tensorflow==1.15.2
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/intel-tensorflow/
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/intel-tensorflow/
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/intel-tensorflow/
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/intel-tensorflow/
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/intel-tensorflow/
Could not fetch URL https://pypi.org/simple/intel-tensorflow/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/intel-tensorflow/ (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 intel-tensorflow==1.15.2 (from versions: none)
ERROR: No matching distribution found for intel-tensorflow==1.15.2
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
为什么会发生这种情况?它再次显示所有pip3的相同错误。7安装,无论我要安装哪个模块。而且,每当我使用系统默认的python版本(Python3.8.2
)时,也不会出现类似的问题。
TL;DR您可能缺少一些系统依赖项<代码>sudo apt安装构建必需的zlib1g dev libncurse5 dev libgdbm dev libnss3 dev libssl dev libreadline dev libffi dev wget
阅读下面关于我们如何到达那里的全部细节。
该错误表示SSL python模块不可用;这意味着您要么没有安装适当的ssl库(可能不是因为您声明系统python可以很好地进行pip安装),要么您从源代码构建或以其他方式安装的python不包含ssl模块。
如果从源代码构建,则需要确保设置配置选项--with-openssl
。
另外,我也要提醒sudo pip不要安装任何东西。使用virtualenv之类的工具,将python环境与系统python或安装的其他python版本分开。
编辑:
仔细检查后,python配置脚本似乎默认启用了ssl支持,假设存在dev标题。确保所有的dev头都存在于sudo apt安装构建必要的zlib1g-dev libncuress5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
中,然后重试配置和构建python。