Disable `pip install` Timeout For Slow Connections
Asked Answered
R

4

7

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.

Roundup answered 18/1, 2020 at 1:8 Comment(4)
Can't --timeout <sec> Set the socket timeout (default 15 seconds). work?Lucan
You can also set the default timeout in a pip config file pip.pypa.io/en/stable/user_guide/#configurationSousaphone
I feel so stupid. Thanks! Seems to be working. I swear I googled this before I posted, don't know how I missed this. If you want to post this as an answer I will be happy to approve it and upvoteRoundup
technically correct answer, but could do without the preachy scold.Abad
L
13

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.

Lucan answered 18/1, 2020 at 2:7 Comment(0)
P
1

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 ~\AppData\Roaming\pip in the case of Windows operating system. If the file does not exist there, create it and write:

[global]
timeout = 30
.
Puritanism answered 4/12, 2022 at 17:55 Comment(1)
pip config set global.timeout 30Defiance
W
1

You may also consider utilising the --retries <retries> flag where you can specify the number of retries (in case of connection failure) before the operation is cancelled.


Note that it can be used along with the above mentioned "--timeout " flag for more control over the connection persistence and stability.

Example:-

pip install numpy --retries 10 --timeout 360

Wenn answered 19/12, 2023 at 23:3 Comment(0)
V
0

Changing timeouts only delays the fault. Disabling ipv6 was the solution for me.

Vernal answered 7/8 at 1:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.