When working on Python projects, it's essential to manage dependencies efficiently. Keeping track of which packages a project relies on and understanding the dependencies between them can sometimes become a complex task. This is where pipdeptree comes to the rescue. The pipdeptree is a command line tool that provides a visual representation of a project's dependency tree. It shows a clear overview of all the packages the project depends on and their interdependencies. This tutorial shows how to get dependency tree of Python packages using pipdeptree.
Before starting, install the pipdeptree
using pip
:
pip install pipdeptree
The following command generates a dependency tree:
pipdeptree -fl
- The
-f
option generates a dependency tree while displaying the exact version of each installed package. It provides a freeze-style output, similar to thepip freeze
command. - The
-l
option limits the dependency tree output to only the packages installed locally within the current Python environment. It excludes system-wide or globally installed packages from the tree, providing a focused view of the dependencies specific to the project.
Here's an example output:
pandas==2.0.2
numpy==1.25.0
python-dateutil==2.8.2
six==1.16.0
pytz==2023.3
tzdata==2023.3
pip==22.3.1
pipdeptree==2.9.3
setuptools==65.5.1
wheel==0.38.4
Leave a Comment
Cancel reply