I'm looking for installation tree in python, meaning which imported requirement requires a specific package.
Is there an efficient/easy way producing the tree?
As one of the comments mentioned, pipdeptree
is a great tool.
If you are using pyenv
, it may not produce accurate results and you may have to run it like this:
pip install pipdeptree
python -m pipdeptree
Another great tool which serves a slightly different purpose is pip-compile
which comes with pip-tools
.
It allows you to generate a requirements file (for pip install
) that contains all the packages and versions while also showing which packages have been pulled in by what.
The resulting requirements.txt
file will look like this:
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file=requirements.txt requirements.in
#
alembic==1.5.5
# via flask-migrate
click==7.1.2
# via flask
dnspython==2.1.0
# via email-validator
dominate==2.6.0
# via flask-bootstrap
...
...
...