How to Solve Readtimeouterror: Httpsconnectionpool(Host='Pypi. Python. Org', Port=443) with Pip?

How to Solve Readtimeouterror: Httpsconnectionpool(Host='Pypi. Python. Org', Port=443) with Pip?

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 sudo before them but all it came up with the following errors in red lines:

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

8 Answers

Use --default-timeout=100 parameter with the install:

sudo pip install --default-timeout=100 future
8
sudo pip install --default-timeout=100 future 

or alternatively

export PIP_DEFAULT_TIMEOUT=100

worked for me on Mac OS X

They are two ways to handle this issue:

sudo pip install --default-timeout=100 future

or

pip install --default-timeout=100 future

Note: If you are not superuser of your machine, the sudo pip command will not work.

1

Upgrading pip solved the problem for me.

python -m pip install --upgrade pip

Change the value of PIP_DEFAULT_TIMEOUT (the value is an integer in seconds).

set PIP_DEFAULT_TIMEOUT=1200

Just throwing this out there to avoid any confusion, for pip3 you can use

sudo pip3 install --default-timeout=100 future

If you are using JetBrains PyCharm, the appropriate solution steps are :

  1. connect to terminal/open terminal in PyCharm.

  2. type source <path to your projects environment eg: /users/name/myapp/venv>

  3. Run pip install <package name> or run pip3 install <package name> as per your installation

This will automatically install package for your interpreter.

My problem was that pip couldn't load a specific version of a package, which lead to the same error message i.e. ReadTimeoutError. Try to find the failing package and update it to the latest version.

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.