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

Question:

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'
Asked By: Ateeb

||

Answers:

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

sudo pip install --default-timeout=100 future
Answered By: Ateeb
sudo pip install --default-timeout=100 future 

or alternatively

export PIP_DEFAULT_TIMEOUT=100

worked for me on Mac OS X

Answered By: Jagdish

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.

Answered By: ARB

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.

Answered By: vegetarianCoder

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

sudo pip3 install --default-timeout=100 future
Answered By: Aniruddha J

Upgrading pip solved the problem for me.

python -m pip install --upgrade pip
Answered By: Bálint Sass

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.

Answered By: Nursultan Imanov
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.