pipdeptree
pipdeptree is a command-line utility that displays the installed Python packages in a dependency tree format. It helps visualize package relationships and identify issues like duplicate or conflicting dependencies. Maintained by the tox-dev team, it is actively developed with frequent minor releases, currently at version 2.34.0.
Warnings
- breaking Python 3.9 support was dropped in version 2.29.0. Users on Python 3.9 or older must upgrade their Python version or use pipdeptree < 2.29.0.
- breaking For programmatic users, render functions (e.g., `render_json`, `render_text`) now print directly to standard output instead of returning a string. This change was introduced in version 2.29.0.
- gotcha The `--output` option was introduced in 2.30.0 to centralize output format selection. While older flags like `--json` may still work, `--output=json`, `--output=dot`, etc., are the preferred and more consistent way to specify formats.
- gotcha pipdeptree is primarily a command-line interface (CLI) tool. While it exposes some internal components for programmatic use, its public API for direct imports might not be as stable or fully documented as its CLI interface.
Install
-
pip install pipdeptree
Imports
- PackageDAG
from pipdeptree import PackageDAG
- render_json
from pipdeptree import render_json
Quickstart
pip install virtualenv python -m venv .venv source .venv/bin/activate pip install requests pipdeptree # Display as JSON pipdeptree --output=json # Display only top-level packages (depth 1) pipdeptree --depth 1