141

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'
cs95
  • 330,695
  • 80
  • 606
  • 657
Ateeb
  • 4,169
  • 3
  • 9
  • 17
  • 3
    Unless there's actually a error called Red Screen Errors, don't put that as the title – Taku Apr 08 '17 at 18:35
  • 4
    I think it's network problem try `ping pypi.python.org` see if it works. It can be solved with something as simple as restarting your router or reconnecting to your internet or even just trying again after sometime. please follow [How to ask](https://stackoverflow.com/help/how-to-ask) before posting here. – Krishna Chaitanya Kornepati Apr 08 '17 at 18:39
  • 1
    This could also happen if there it has to by pass proxy. Do: pip install future --proxy= – user3885927 Feb 27 '18 at 18:40
  • 1
    I solve it with stopping openconnect proxy :| :)) – Mojtaba Arvin Aug 17 '18 at 06:04

4 Answers4

259

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

sudo pip install --default-timeout=100 future
pkamb
  • 30,595
  • 22
  • 143
  • 179
Ateeb
  • 4,169
  • 3
  • 9
  • 17
  • 24
    Alternatively, I used `export PIP_DEFAULT_TIMEOUT=100` since I had the `pip` command in a shared Dockerfile and it was a temporary requirement for me. But it works, thanks! – Kerem Nov 15 '17 at 12:15
  • 9
    Thanks, It saves me in slow internet condition. I guess 100 is the the number of seconds pip'll wait for the reconnect after losing connection? – Khanh Le Nov 17 '17 at 07:15
  • 1
    Can I make the timeout setting permament? – Timo Mar 30 '18 at 08:05
  • 1
    I cannot find the setting with `pip help` or `pip install help`. There is howerver `socket timeout`. I wonder what is the default value? – Timo Mar 30 '18 at 08:10
  • 1
    I cannot find the setting with `pip help` or `pip install help`. There is howerver `socket timeout`. I wonder what is the default value? – Timo Mar 30 '18 at 08:10
  • 1
    @Timo, use @Kerem's command (`export PIP_DEFAULT_TIMEOUT=100`) in your `~/.profile` to make it permanent. – Chinoto Vokro Jun 29 '20 at 20:56
  • As per [this comment](https://stackoverflow.com/questions/50305112/pip-install-timeout-issue#comment117142274_61472212) by [asmaier](https://stackoverflow.com/users/179014/asmaier) on [Pip Install Timeout Issue](https://stackoverflow.com/q/50305112/1364007), the parameter may be `--timeout` rather than `--default-timeout`. – Wai Ha Lee Jan 13 '22 at 07:48
23
sudo pip install --default-timeout=100 future 

or alternatively

export PIP_DEFAULT_TIMEOUT=100

worked for me on Mac OS X

pkamb
  • 30,595
  • 22
  • 143
  • 179
Jagdish
  • 384
  • 2
  • 9
5

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.

pkamb
  • 30,595
  • 22
  • 143
  • 179
ARB
  • 181
  • 2
  • 6
0

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.

vegetarianCoder
  • 2,254
  • 2
  • 15
  • 24