pipdeptree utility
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.
This module does not come built-in with Python. To install it type the below command in the terminal.
$pip install pipdeptree
This will install the latest version of pipdeptree which requires at least Python 2.7.
Now run this command on command prompt to get a dependency tree of all your Python modules.
Command:
$pipdeptree
Output:
$pipdeptree altair==4.1.0 - entrypoints [required: Any, installed: 0.3] - jinja2 [required: Any, installed: 2.11.2] - MarkupSafe [required: >=0.23, installed: 1.1.1] - jsonschema [required: Any, installed: 3.2.0] - attrs [required: >=17.4.0, installed: 19.3.0] - pyrsistent [required: >=0.14.0, installed: 0.16.0] - six [required: Any, installed: 1.15.0] - setuptools [required: Any, installed: 41.2.0] - six [required: >=1.11.0, installed: 1.15.0] - numpy [required: Any, installed: 1.18.4] - pandas [required: >=0.18, installed: 1.0.4] - numpy [required: >=1.13.3, installed: 1.18.4] - python-dateutil [required: >=2.6.1, installed: 2.8.1] - six [required: >=1.5, installed: 1.15.0] - pytz [required: >=2017.2, installed: 2020.1] - toolz [required: Any, installed: 0.10.0] docutils==0.15.2 jmespath==0.10.0 opencv-python==4.2.0.34 - numpy [required: >=1.17.3, installed: 1.18.4] pipdeptree==1.0.0 - pip [required: >=6.0.0, installed: 20.2.1] urllib3==1.25.9
Dependency tree of a Python Module
Generally, many Python packages are dependent on other packages but how do we know that on which packages is a module dependent?