If I want to use the pip
command to download a package (and its dependencies), but keep all of the zipped files that get downloaded (say, django-socialregistration.tar.gz) - is there a way to do that?
I've tried various command-line options, but it always seems to unpack and delete the zipfile - or it gets the zipfile, but only for the original package, not the dependencies.
In version 7.1.2 pip downloads the wheel of a package (if available) with the following:
The following downloads a source distribution:
These download the dependencies as well, if pip is aware of them (e.g., if
pip show package
lists them).Update
As noted by Anton Khodak,
pip download
command is preferred since version 8. In the above examples this means that/path/to/downloaded/file
needs to be given with option-d
, so replacinginstall
withdownload
works.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 fromrequirement.txt
:pip install -r requirement.txt
REFERENCE: pip installer
The
--download-cache
option should do what you want: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.)The
pip
documentation outlines using--download
for fast & local installs.pip wheel
is another option you should consider:It will download packages and their dependencies to a directory (current working directory by default), but it performs the additional step of converting any source packages to wheels.
It conveniently supports requirements files:
Add the
--no-deps
argument if you only want the specifically requested packages:Use
pip download <package1 package2 package n>
to download all the packages including dependenciesUse
pip install --no-index --find-links . <package1 package2 package n>
to install all the packages including dependencies. It gets all the files fromCWD
. It will not download anythingpip install --download
is deprecated. Starting from version 8.0.0 you should usepip download
command: