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

时间:2017-04-08 18:31:18

标签: python pip

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

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

我也尝试过在他们面前写sudo,但所有这些都是红线中出现以下错误:

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'

3 个答案:

答案 0 :(得分:86)

Yaayy! 我找到了答案。 只需在安装时使用--default-timeout = 100参数即可。 e.g

sudo pip install --default-timeout=100 future

答案 1 :(得分:8)

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

或者

导出PIP_DEFAULT_TIMEOUT = 100 在Mac osx上为我工作了

答案 2 :(得分:0)

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

第一种方法:

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

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

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