Get Dependency Tree of Python Packages using pipdeptree

Get Dependency Tree of Python Packages using pipdeptree

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 the pip 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:


Leave a Comment

Cancel reply

Your email address will not be published.