首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SSLError(“无法连接到HTTPS,因为SSL模块不可用”)。在pip命令中

SSLError(“无法连接到HTTPS,因为SSL模块不可用”)。在pip命令中
EN

Stack Overflow用户
提问于 2020-07-25 03:35:31
回答 1查看 35.9K关注 0票数 11

在我的Ubuntu 20.04里。我正在使用两个python版本。其中一个是随我的Ubuntu安装而来的Ubuntu,另一个是Python3.7.5。我在系统默认版本的同时使用update-alternatives安装了update-alternatives。但是现在的问题是没有pip命令在Python3.7.5上工作。尽管pip在此(Python3.7.5)安装中可用,并且在打印版本时,它显示了以下内容(使用命令pip3.7 -V):

代码语言:javascript
复制
pip 19.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

但是,每当我试图使用它来安装一个软件包时,总是会显示标题中提到的错误。例如,在安装以下软件包时:

代码语言:javascript
复制
sudo pip3.7 install intel-tensorflow==1.15.2

引发以下错误:

代码语言:javascript
复制
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)时,也不会出现类似的问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-25 03:46:05

您可能缺少了一些系统依赖关系。sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

请阅读下面的详细信息,了解我们是如何到达那里的。

错误声明SSL python模块不可用;这意味着您要么没有安装适当的ssl库(可能因为您声明了系统python可以很好地执行pip ),要么您从源代码构建的python或以其他方式安装的python不包括ssl模块。

如果您从源代码构建它,则需要确保设置配置选项--with-openssl

另外,我真的要警告不要安装任何东西的sudo pip。使用类似于维塔列夫的东西,可以将python环境与您安装的系统python或其他python版本分开。

编辑:

仔细研究后,假设出现了dev头,python配置脚本在默认情况下似乎启用了ssl支持。确保sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget中存在所有的dev头,然后重新尝试配置和构建python。

票数 17
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63084049

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档