I install a lot of the same packages in different virtualenv environments. Is there a way that I can download a package once and then have pip install from a local cache?
This would reduce download bandwidth and time.
I install a lot of the same packages in different virtualenv environments. Is there a way that I can download a package once and then have pip install from a local cache?
This would reduce download bandwidth and time.
Using pip only (my version is 1.2.1), you can also build up a local repository like this:
In the first call of pip, the packages from the requirements file are looked up in the local repository (only), and then installed from there. If that fails, pip retrieves the packages from its usual location (e.g. PyPI) and downloads it to the
PIP_SDIST_INDEX
(but does not install anything!). The first call is "repeated" to properly install the package from the local index.(
--download-cache
creates a local file name which is the complete (escaped) URL, and pip cannot use this as an index with--find-links
.--download-cache
will use the cached file, if found. We could add this option to the second call of pip, but since the index already functions as a kind of cache, it does not necessarily bring a lot. It would help if your index is emptied, for instance.)I think the package "pip-accel" must be a good choice.
For newer Pip versions:
Newer Pip versions now cache downloads by default. See this documentation:
https://pip.pypa.io/en/stable/reference/pip_install/#caching
For older Pip versions:
Create a configuration file named
~/.pip/pip.conf
, and add the following contents:On OS X, a better path to choose would be
~/Library/Caches/pip
since it follows the convention other OS X programs use.Updated Answer 19-Nov-15
According to the Pip documentation:
Therefore, the updated answer is to just use pip with its defaults if you want a download cache.
Original Answer
From the pip news, version 0.1.4:
To take advantage of this, I've added the following to my
~/.bash_profile
:or, if you are on a Mac:
Notes
PIP_DOWNLOAD_CACHE
directory. For instance, I now have quite a few Django packages.virtualenvs
on the airplane, but it's still great.There is a new solution to this called pip-accel, a drop-in replacement for
pip
with caching built in.We've seen around 10x speedup from switching from
pip
topip-accel
.Starting in version 6.0,
pip
now does it's own caching:More information from the above link: