Without going through with the installation, I want to quickly see all the packages that pip install
would install.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
IN CASE you have the packages already installed, this script can fetch all the dependencies from a requirements file by running the command
pip show
mentioned by @Sardathrion.The closest you can get with pip directly is by using the
--no-install
argument:For example, this is the output when installing celery:
Admittedly, this does leave some cruft around in the form of temporary files, but it does accomplish the goal. If you're doing this with virtualenv (which you should be), the cleanup is as easy as removing the
<virtualenv root>/build
directory.Another option is to use a helper script similar to this one which uses the
pip.req.parse_requirements
API to parserequirements.txt
files and adistutils.core.setup
replacement to parsesetup.py
files.The command
pip install <package> --download <path>
should be used, as mentioned in comments by @radtek, since as of 7.0.0 (2015-05-21), --no-install is removed frompip
. This will download the dependencies needed into<path>
.The accepted answer is no longer relevant for more current versions of pip and does not give an immediate answer without perusing multiple comments so I am providing an updated answer.
This was tested with pip versions 8.1.2, 9.0.1 and 10.0.1.
To get the output without cluttering your current directory on Linux use
-d
tells pip the directory that download should put files in.Better, just use this script with the argument being the package name to get only the dependencies as output:
Also available here.
The answer by @Jmills is stellar. It has a bug in the negative matching which causes some dependencies to be missed. In order to ensure that a package is not marked as a dependency of itself, he included the line
grep -v $PACKAGE
, which also negatively matches any dependency with the original package name as a sub-string, sojupyter_core
is not listed as a dependency ofjupyter
, for example.For my use case, I found it useful to have an implementation in python code instead of a shell script. I haven't included the original bug, though anyone is free to add it back in if they would like. I've borrowed an stdout capturing context manager to hopefully make the dependency gathering more intuitive.
In case you don't need the version numbers, those are easy enough to filter out.