由于环境错误而无法安装软件包:HTTPSConnectionPool

时间:2020-09-22 15:05:33

标签: python pip environment

我试图像往常一样安装一些python软件包,并收到以下警告和错误:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7ffaa13b1250>: Failed to establish a new connection: [Errno -2] Name or service not known')': /packages/4e/5f/528232275f6509b1fff703c9280e58951a81abe24640905de621c9f81839/pip-20.2.3-py2.py3-none-any.whl

此警告显示5次,最后显示错误:

ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/4e/5f/528232275f6509b1fff703c9280e58951a81abe24640905de621c9f81839/pip-20.2.3-py2.py3-none-any.whl (Caused by NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7ffaa1423610>: Failed to establish a new connection: [Errno -2] Name or service not known')

我也尝试用python -m install --upgrade pip升级点,并获得相同的准确输出。
我看到了类似的SO帖子,它们建议使用此命令pip install --user <package_name>,但对我而言不起作用-我遇到相同的错误。

我还尝试使用不同的环境和不同的路径,但输出是相同的。

OS是Linux。

编辑:我什么也没做,只是尝试在几个小时后再次安装软件包,现在就可以使用了。

2 个答案:

答案 0 :(得分:0)

一旦我的网络连接不稳定,就会遇到此问题。尝试使用其他路由器或调制解调器

答案 1 :(得分:0)

由于Docker not syncing with the host machine's clock错误,

通过修复该错误并运行docker run --rm --privileged alpine hwclock -s

可以解决此问题。