1

I have a requirements.txt file with several dependencies listed.

Whenever I try pip install -r requirements.txt in a brand new system, this will usually fail when some dependency is not met (see for example: here and here) This happens specially with the matplotlib package.

After downloading the entire package (in the case of matplotlib it's about 50Mb) and failing to install it, I go and fix the issue and then attempt to install the package again.

pip does not seem to be smart enough to realize it just downloaded that package and automatically re-use that same file (perhaps because it keeps no copy by default?) so the package will be downloaded entirely again.

To get around this issue I can follow the instructions given here and use:

pip install --download=/path/to/packages -r requirements.txt

to first download all packages and then:

pip install --no-index --find-links=/path/to/packages -r requirements.txt

to install all the packages using the locally stored files.

My question: is there a smart command that includes both these directives? I'm after a single line I can run repeatedly so that it will use stored copies of the packages if they exist or download them if they don't, and in this last case, store those copies to some location so they can be re-used later on if needed.

Community
  • 1
  • 1
Gabriel
  • 40,504
  • 73
  • 230
  • 404

0 Answers0