如何使用pip解决ReadTimeoutError:HTTPSConnectionPool(host ='pypi.python.org',port = 443)?


91

我最近需要安装一些软件包

pip install future
pip install scikit-learn
pip install numpy
pip install scipy

sudo在他们之前也尝试过writin ,但是所有这些都以红线显示了以下错误:

Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 290, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1198, in prepare_files
    do_download,
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1376, in unpack_url
    self.session,
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 572, in unpack_http_url
    download_hash = _download_url(resp, link, temp_location)
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 433, in _download_url
    for chunk in resp_read(4096):
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 421, in resp_read
    chunk_size, decode_content=False):
  File "/usr/lib/python2.7/dist-packages/urllib3/response.py", line 256, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/lib/python2.7/dist-packages/urllib3/response.py", line 201, in read
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.

Storing debug log for failure in /root/.pip/pip.log'

2
除非实际上存在一个称为“红色屏幕错误”的错误,否则不要将其作为标题
abccd

4
我认为这是网络问题,请尝试ping pypi.python.org看看是否可行。只需重启路由器或重新连接到互联网,甚至在一段时间后重试即可。在此处发布之前,请先遵循“如何提问”
克里希纳(Krishna)Chaitanya Kornepati'4

如果必须通过代理,也可能发生这种情况。做:pip install future --proxy = <您的代理站点>
user3885927 '18年

我通过停止openconnect代理来解决它::))
Mojtaba Arvin

Answers:


174

耶!我找到了答案。只需在安装中使用--default-timeout = 100参数即可。例如

sudo pip install --default-timeout=100 future

16
另外,export PIP_DEFAULT_TIMEOUT=100由于使用pip了共享Dockerfile中的命令,所以我使用了它,这是我的临时要求。但这有效,谢谢!
凯雷姆

8
谢谢,它使我免于处于缓慢的互联网状态。我猜是失去连接后pip'll等待重新连接的秒数是100吗?
LittleZero

1
我可以设置超时设置吗?
Timo

1
我用pip help或无法找到设置pip install help。有how socket timeout。我想知道默认值是多少?
蒂莫

1
我用pip help或无法找到设置pip install help。有how socket timeout。我想知道默认值是多少?
蒂莫

8

sudo pip install --default-timeout = 100将来

或者

export PIP_DEFAULT_TIMEOUT = 100在Mac OS X上为我工作


0

它们是解决此问题的两种方法。

第一种方法:

sudo pip install --default-timeout = 100将来

第二个:pip install --default-timeout = 100 future。

注意:如果您不是计算机的超级用户,则sudo pip命令将不起作用。(发生在我身上。)


1
注意,对pip使用'sudo'不是一个好主意。请改用'--user'标志。
8:51会见Sinojia
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.