Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to force pip install to retry on requirements install failure?

I'm trying to install some pip requirements in a container I build. But due to my setup (docker build runs in a VM on a system connected over VPN to the network where the git server is located. COVID-19 situation) I get the error below. I know the issue is caused by my setup as sometimes works fine. Plus if i run the same docker build on a machine within the same network with the git server, also works fine. I spend some time to try to figure out my network problem, but haven't found any proper solution yet. So knowing that some time the pin install git clone works, i was wondering if there is any way of instructing pip to retry the installation o failed component, until it succeeds?

This is how I call pip install:

pip install --no-cache-dir --disable-pip-version-check -r requirements.txt

The git lab repo URL is properly defined in the requirements.txt

Thanks

Collecting git+https://gitlab%2Bdeploy-token-98:****@git.my.host.com/core-tech/tools/nlu/[email protected] (from -r requirements.txt (line 19))
  Cloning https://gitlab%2Bdeploy-token-98:****@git.my.host.com/core-tech/tools/nlu/trsx-converter.git (to revision 0.0.3) to /tmp/pip-req-build-t8m2io14
  Running command git clone -q 'https://gitlab%2Bdeploy-token-98:****@git.my.host.com/core-tech/tools/nlu/trsx-converter.git' /tmp/pip-req-build-t8m2io14
  fatal: unable to access 'https://git.my.host.com/core-tech/tools/nlu/trsx-converter.git/': The requested URL returned error: 511                                                                                                       
ERROR: Command errored out with exit status 128: git clone -q 'https://gitlab%2Bdeploy-token-98:****@git.my.host.com/core-tech/tools/nlu/trsx-converter.git' /tmp/pip-req-build-t8m2io14 Check the logs for full command output.      
like image 263
gheorghi evgheniev Avatar asked Mar 03 '23 16:03

gheorghi evgheniev


1 Answers

There's a --retries option on the pip install command:

pip install --help

General Otions:

  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).

It's 5 by default, so I'm not sure it will actually fix your issue, but you could try with a higher value, just in case.

like image 83
Agate Avatar answered Mar 05 '23 15:03

Agate