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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43298872/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 22:50:03  来源:igfitidea点击:

How to solve ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443) with pip?

pythonpip

提问by Ateeb

I recently need to install some packages

我最近需要安装一些包

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

I also tried by writin sudobefore them but all it came up with the following errors in red lines:

我也在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'

回答by Ateeb

Yaayy ! I have found the answer. Just use --default-timeout=100 parameter with the install. e.g

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

sudo pip install --default-timeout=100 future

回答by Jagdish

sudo pip install --default-timeout=100 future

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

or alternatively

或者

export PIP_DEFAULT_TIMEOUT=100 worked for me on mac osx

export PIP_DEFAULT_TIMEOUT=100 在 mac osx 上为我工作

回答by ARB

They are two ways to handlie this issue.

它们是处理这个问题的两种方法。

First method:

第一种方法:

sudo pip install --default-timeout=100 future

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

Second one: pip install --default-timeout=100 future.

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

Note: If you are not superuser of your machine, sudo pip command, will not work. (Its happened with me.)

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