This question already has an answer here:
How do you prevent PIP from re-downloading previously downloaded packages? I'm testing the install of matplotlib, an 11MB package that depends on several distro-specific packages. Everytime I run pip install matplotlib
, it re-downloads matplotlib. How do I stop this?
For new Pip versions:
Newer Pip versions by default now cache downloads. See this documentation:
https://pip.pypa.io/en/stable/reference/pip_install/#caching
For old Pip versions:
Create a configuration file named
~/.pip/pip.conf
, and add the following contents:In one command:
You could
Also, you could manually download the package
Then install it by un-tar and
python setup install
later.The
pip install --download-cache
works in a similar way w/ extra checking: it firstly search for the latest or specified version of the target package from web, if the search has result and there is cached package in the directory specified bydownload-cache
, the cached package will be used instead of downloading. For example,will download pymongo package to current directory:
You can use a specific environment variable PIP_DOWNLOAD_CACHE and make it point to a directory where your packages will be stored. If they are to be installed again, they will be taken from this directory.
There seems to be also an additional option for PIP
pip --download-cache
which ought to do something similar, but I have never tried it myself. For your example, to avoid re-downloadingmatplotlib
every time, you would do the following:Does that answer your question?