由于环境错误,pip安装pandas失败。

11

我正在尝试安装pandas,但是出现了以下错误:

Collecting pandas

Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)")': /packages/26/fc/d0509d445d2724fbc5f9c9a6fc9ce7da794873469739b6c94afc166ac2a2/pandas-0.23.4-cp37-cp37m-win32.whl 
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)")': /packages/26/fc/d0509d445d2724fbc5f9c9a6fc9ce7da794873469739b6c94afc166ac2a2/pandas-0.23.4-cp37-cp37m-win32.whl 
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)")': /packages/26/fc/d0509d445d2724fbc5f9c9a6fc9ce7da794873469739b6c94afc166ac2a2/pandas-0.23.4-cp37-cp37m-win32.whl 
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)")': /packages/26/fc/d0509d445d2724fbc5f9c9a6fc9ce7da794873469739b6c94afc166ac2a2/pandas-0.23.4-cp37-cp37m-win32.whl 
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)")': /packages/26/fc/d0509d445d2724fbc5f9c9a6fc9ce7da794873469739b6c94afc166ac2a2/pandas-0.23.4-cp37-cp37m-win32.whl 
Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/26/fc/d0509d445d2724fbc5f9c9a6fc9ce7da794873469739b6c94afc166ac2a2/pandas-0.23.4-cp37-cp37m-win32.whl (Caused by ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)"))

我正在以管理员身份运行命令提示符,并键入pip install pandas。我的pip版本为18.1。我还尝试在Python的脚本目录中通过Windows PowerShell运行此命令。

我以前从未安装过软件包出现过问题。

这个错误是什么原因引起的,如何解决?


1
尝试在公司网络中使用pip install pandas--trusted-host pypi.python.org - anky
我通过使用“--trusted-host files.pythonhosted.org”成功使其工作。 - Travis
5个回答

13

看起来您正在企业网络上安装且有防火墙,可以尝试连接到另一个WiFi或热点并再次尝试下载吗?


7

看起来您与服务器的连接速度较慢。尝试增加超时时间:

sudo pip install --default-timeout=120 pandas

或者,您可以使用:

export PIP_DEFAULT_TIMEOUT=120

这是pip在决定连接超时之前等待的时间(以秒为单位)(现在在您的情况下为15秒-“read timeout=15”)


我刚刚尝试了一下,结果得到了完全相同的错误。我还尝试更改网络,但也没有起作用。 - JackU
你能访问服务器吗?尝试在浏览器中打开https://files.pythonhosted.org/。 - Lukasz Korbasiewicz
我无法连接到服务器,连接超时了。这可能是我的问题还是他们的问题? - JackU
我会说是你这边,或者在你和他们之间(你的ISP?)。 我可以联系到他们。 - Lukasz Korbasiewicz
我遇到了相同的问题,我曾经连接到我的公司VPN,现在我得到了相同的错误,我已经添加了全局受信任站点,并尝试在命令中添加受信任站点,但似乎都不起作用。 - goose
我尝试了所有的方法,但有趣的是,“export PIP_DEFAULT_TIMEOUT=120”解决了这个问题。 - Neeraj Gulia

4
如果您以管理员用户身份登录仍然遇到此问题,可能有三个原因:
  1. 您的计算机/公司防火墙不允许您安装/升级任何模块。(请联系支持部门)。
  2. WiFi速度太慢。(其他用户提到了修复方法)。
  3. 听起来很傻,但最常见的原因是,在安装Python后没有重新启动计算机。(尝试重新启动)。
如果这对您或任何阅读此评论的人有所帮助,请告诉我。

1

配置pip信任files.pythonhosted.org主机:

pip config set --user global.trusted-host files.pythonhosted.org

你就应该能够执行安装了。


0

修复 --> 错误:由于OSError而无法安装软件包:HTTPSConnectionPool(host ='files.pythonhosted.org',port = 443):超过了url的最大重试次数:<...>(由SSLError(SSLCertVerificationError(1,'[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败:无法获取本地颁发者证书(_ssl.c:997)'))引起)

  1. 断开VPN客户端连接
  2. 重新发出CMD命令> pip install robotframework ... 成功安装pip-21.3.1

目前你的回答不够清晰,请编辑并添加更多细节,以帮助其他人理解它如何回答问题。你可以在帮助中心找到有关如何撰写好答案的更多信息。 - Community

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