I would like to analyze the dependency tree of Python packages. How can I obtain this data?
Things I already know
setup.py
sometimes contains a requires
field that lists package dependenciesThings that I don't know
requires
field but pip/easy_install
still manage to download the correct packages. What am I missing? For example the popular library for statistical computing, pandas
, doesn't list requires
but still manages to install numpy
, pytz
, etc.... Is there a better way to automatically collect the full list of dependencies?One easy way of doing so is to use the pipdeptree utility. The pipdeptree works on the command line and shows the installed python packages in the form of a dependency tree.
Pip Check Command – Check Python Dependencies After Installation. Because pip doesn't currently address dependency issues on installation, the pip check command option can be used to verify that dependencies have been installed properly in your project. For example: $ pip check No broken requirements found.
You can do it by installing pipdeptree package. Open command prompt in your project folder. If you are using any virtual environment, then switch to that virtual environment. This package will list all the dependencies of your project.
Dependencies are all of the software components required by your project in order for it to work as intended and avoid runtime errors. You can count on PyPI (the Python Package Index) to provide packages that can help you get started on everything from data manipulation to machine learning to web development, and more.
You should be looking at the install_requires
field instead, see New and changed setup
keywords.
requires
is deemed too vague a field to rely on for dependency installation. In addition, there are setup_requires
and test_requires
fields for dependencies required for setup.py
and for running tests.
Certainly, the dependency graph has been analyzed before; from this blog article by Olivier Girardot comes this fantastic image:
The image is linked to the interactive version of the graph.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With