How to use Python's pip to download and keep the zipped files for a package?
The --download-cache
option should do what you want:
pip install --download-cache="/pth/to/downloaded/files" package
However, when I tested this, the main package downloaded, saved and installed ok, but the the dependencies were saved with their full url path as the name - a bit annoying, but all the tar.gz
files were there.
The --download
option downloads the main package and its dependencies and does not install any of them. (Note that prior to version 1.1 the --download
option did not download dependencies.)
pip install package --download="/pth/to/downloaded/files"
The pip
documentation outlines using --download
for fast & local installs.
pip install --download
is deprecated. Starting from version 8.0.0 you should use pip download
command:
pip download <package-name>
I always do this to download the packages:
pip install --download /path/to/download/to_packagename
OR
pip install --download=/path/to/packages/downloaded -r requirements.txt
And when I want to install all of those libraries I just downloaded, I do this:
pip install --no-index --find-links="/path/to/downloaded/dependencies" packagename
OR
pip install --no-index --find-links="/path/to/downloaded/packages" -r requirements.txt
Update
Also, to get all the packages installed on one system, you can export them all to requirement.txt
that will be used to intall them on another system, we do this:
pip freeze > requirement.txt
Then, the requirement.txt
can be used as above for download, or do this to install them from requirement.txt
:
pip install -r requirement.txt
REFERENCE: pip installer