Disable `pip install` Timeout For Slow Connections

Question:

I recently moved to a place with terrible internet connection. Ever since then I have been having huge issues getting my programming environments set up with all the tools I need – you don’t realize how many things you need to download until each one of those things takes over a day.
For this post I would like to try to figure out how to deal with this in pip.

The Problem
Almost every time I pip install something it ends out timing out somewhere in the middle. It takes many tries until I get lucky enough to have it complete without a time out. This happens with many different things I have tried, big or small. Every time an install fails the next time starts all over again from 0%, no matter how far I got before.
I get something along the lines of

pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

What I want to happen
Ideally I would like to either extend the definition of time pip uses before it declares a timeout or be able to disable the option of a timeout all together.
I am not sure either of these are possible, so if anyone has any other solution for me that would be greatly appreciated as well.

Other Information
Not sure this helps any but what I found is that the only reliable way for me to download anything here is using torrents, as they do not restart a download once they lose connection, rather they always continue where they left off. If there is a way to use this fact in any way that would be nice too.

Asked By: Oha Noch

||

Answers:

Use option --timeout <sec> to set socket time out.

Also, as @Iain Shelvington mentioned, timeout = <sec> in pip configuration will also work.

TIP: Every time you want to know something (maybe an option) about a command (tool), before googling, check the manual page of the command by using man <command> or use <command> --help or check that command's docs online will be very useful too.

Answered By: xiaoyu2006

To set the timeout time to 30sec for example. The easiest way is executing: pip config global.timeout 30 or going to the pip configuration file pip.ini located in the directory ~AppDataRoamingpip in the case of Windows operating system. If the file does not exist there, create it and write:

[global]
timeout = 30

.

Answered By: Elbio
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.