如何解决“由于EnvironmentError:HTTPSConnectionPool错误而无法安装软件包”的问题?

27

我正在尝试安装jupyterthemes包时遇到了这个错误。

图片描述

Collecting jupyterthemes
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /packages/8a/08/9dee6dfd7f2aad6c30282d55c8f495b4dc1e4747b4e2bdbeb80572ddf312/jupyterthemes-0.20.0-py2.py3-none-any.whl
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /packages/8a/08/9dee6dfd7f2aad6c30282d55c8f495b4dc1e4747b4e2bdbeb80572ddf312/jupyterthemes-0.20.0-py2.py3-none-any.whl
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /packages/8a/08/9dee6dfd7f2aad6c30282d55c8f495b4dc1e4747b4e2bdbeb80572ddf312/jupyterthemes-0.20.0-py2.py3-none-any.whl
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /packages/8a/08/9dee6dfd7f2aad6c30282d55c8f495b4dc1e4747b4e2bdbeb80572ddf312/jupyterthemes-0.20.0-py2.py3-none-any.whl
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /packages/8a/08/9dee6dfd7f2aad6c30282d55c8f495b4dc1e4747b4e2bdbeb80572ddf312/jupyterthemes-0.20.0-py2.py3-none-any.whl
Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/8a/08/9dee6dfd7f2aad6c30282d55c8f495b4dc1e4747b4e2bdbeb80572ddf312/jupyterthemes-0.20.0-py2.py3-none-any.whl (Caused by ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)))

你似乎在代理后面运行pip,如果是这样,请运行 pip --proxy "在此处输入代理" install jupyterthemes - Mohamed Ali JAMAOUI
6个回答

30

看起来你需要添加可信主机。

查看 GitHub 线程。

类似这样:

sudo pip install --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org --upgrade --proxy=127.0.0.1:3128 jupyterthemes

我无法使用此命令进行安装,因为出现了错误“代理URL没有方案,应该以http://或https://开头”。相反,为了使其正常工作,我使用了不带代理参数的命令:pip3 install --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org geopy - Noah Friedman
使用了--trusted-host=host.com,去掉了代理部分,问题解决了。 - gzcarlosrd

6
请检查日期是否设置正确。当时间和日期与服务器不同时,通常会出现此错误。

我批准,这个程序在午夜后不久就出了问题。由于时区差异,我的本地时间与UTC不同步。 - tiborka

3

您可能已经安装了安全软件。在我的情况下,Zscaler通常是罪魁祸首,但其他安全软件也可能导致此错误被抛出。 VnC的答案通常是一个快速解决方案。请参见解释的永久性修复

总之,您需要在Unix中创建一个配置文件pip.inipip.conf。您需要在文件中包含如下所示的受信任主机:

# for system-wide configuration file
[global]
trusted-host = pypi.python.org
               pypi.org
               raw.githubusercontent.com
               files.pythonhosted.org

# per-user configuration file
[user]
trusted-host = pypi.python.org
               pypi.org
               raw.githubusercontent.com
               files.pythonhosted.org

# per-virtualenv configuration file
[site]
trusted-host = pypi.python.org
               pypi.org
               raw.githubusercontent.com
               files.pythonhosted.org

我使用的是Windows操作系统。请参考文档获取您所使用操作系统的相关信息。


1

对我来说,这是由于网络防火墙设置引起的问题,请尝试连接到其他网络并运行命令。这对我有用。


1
尝试设置代理。
set http_proxy=http://proxy.myproxy.com
set https_proxy=https://proxy.myproxy.com
python get-pip.py

0

我认为有些包需要使用管理员权限来安装,在Mac上尝试以下操作:

sudo pip install

在Windows上:

你必须以管理员身份运行 cmd

我的意思是右键单击cmd,选择

以管理员身份运行 然后 pip install 包名


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接