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

PythonPip

Python Problem Overview


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'

Python Solutions


Solution 1 - Python

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

sudo pip install --default-timeout=100 future

Solution 2 - Python

sudo pip install --default-timeout=100 future 

or alternatively

export PIP_DEFAULT_TIMEOUT=100

worked for me on Mac OS X

Solution 3 - Python

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.

Solution 4 - Python

If you are using Jetbrains Pycharm, the appropriate solution is :

Step -1 : connect to terminal/open terminal in pycharm.

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

Step -3: Run pip install <package name> or Run pip3 install <package name> as per your installation

This will automatically install package for your interpreter.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAteebView Question on Stackoverflow
Solution 1 - PythonAteebView Answer on Stackoverflow
Solution 2 - PythonJagdishView Answer on Stackoverflow
Solution 3 - PythonARBView Answer on Stackoverflow
Solution 4 - PythonvegetarianCoderView Answer on Stackoverflow