or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli-interface.mddata-models.mdenvironment-detection.mdindex.mdoutput-rendering.mdpackage-discovery.mdvalidation.mdwarning-system.md
tile.json

tessl/pypi-pipdeptree

Command line utility to show dependency tree of packages.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pipdeptree@2.28.x

To install, run

npx @tessl/cli install tessl/pypi-pipdeptree@2.28.0

index.mddocs/

pipdeptree

A command-line utility for displaying installed Python packages in a hierarchical dependency tree format. Unlike pip freeze which shows packages as a flat list, pipdeptree visualizes package relationships, identifies conflicting dependencies, supports reverse dependency lookups, and provides multiple output formats including text, JSON, and GraphViz.

Package Information

  • Package Name: pipdeptree
  • Language: Python
  • Installation: pip install pipdeptree
  • Python Version: >=3.9

Core Imports

# CLI entry point
from pipdeptree.__main__ import main

# Core model classes
from pipdeptree._models import DistPackage, ReqPackage, PackageDAG

# Discovery functions
from pipdeptree._discovery import get_installed_distributions

# CLI options
from pipdeptree._cli import get_options, Options

# Validation
from pipdeptree._validate import validate

# Rendering
from pipdeptree._render import render

# Freeze utilities
from pipdeptree._freeze import dist_to_frozen_repr

Basic Usage

Command Line Interface

# Show dependency tree for all packages
pipdeptree

# Show specific packages only
pipdeptree --packages django,requests

# Show reverse dependencies (what depends on a package)
pipdeptree --reverse --packages numpy

# Output as JSON
pipdeptree --json

# Output as nested JSON tree
pipdeptree --json-tree

# Use custom Python interpreter
pipdeptree --python /path/to/python

# Auto-detect virtual environment
pipdeptree --python auto

Programmatic Usage

from pipdeptree._discovery import get_installed_distributions
from pipdeptree._models import PackageDAG
from pipdeptree._validate import validate
from pipdeptree._render import render
from pipdeptree._cli import get_options

# Get installed packages
distributions = get_installed_distributions()

# Create dependency tree
tree = PackageDAG.from_pkgs(distributions)

# Validate for conflicts and cycles
validate(tree)

# Parse CLI options and render
options = get_options(['--json'])
render(options, tree)

Architecture

pipdeptree uses a directed acyclic graph (DAG) structure to represent package dependencies:

  • PackageDAG: Main container mapping packages to their requirements
  • DistPackage: Represents installed distribution packages with metadata
  • ReqPackage: Represents package requirements with version constraints
  • Discovery: Queries Python environments for installed packages
  • Validation: Detects conflicting and circular dependencies
  • Rendering: Outputs trees in various formats (text, JSON, GraphViz, Mermaid)

Capabilities

Package Discovery

Discovers and queries installed Python packages across different environments, interpreters, and installation scopes.

def get_installed_distributions(
    interpreter: str = sys.executable or "",
    supplied_paths: list[str] | None = None,
    local_only: bool = False,
    user_only: bool = False,
) -> list[Distribution]: ...

Package Discovery

Data Models

Core classes for representing packages, requirements, and dependency relationships in a hierarchical structure.

class DistPackage:
    def __init__(self, obj: Distribution, req: ReqPackage | None = None): ...
    def requires(self) -> Iterator[Requirement]: ...
    @property
    def version(self) -> str: ...

class ReqPackage:
    def __init__(self, obj: Requirement, dist: DistPackage | None = None): ...
    @property
    def version_spec(self) -> str | None: ...
    def is_conflicting(self) -> bool: ...

class PackageDAG(Mapping[DistPackage, list[ReqPackage]]):
    @classmethod
    def from_pkgs(cls, pkgs: list[Distribution]) -> PackageDAG: ...
    def filter_nodes(self, include, exclude, exclude_deps=False): ...
    def reverse(self) -> ReversedPackageDAG: ...

Data Models

Dependency Validation

Validates dependency trees to identify conflicting versions and circular dependencies with detailed reporting.

def validate(tree: PackageDAG) -> None: ...
def conflicting_deps(tree: PackageDAG) -> dict[DistPackage, list[ReqPackage]]: ...
def cyclic_deps(tree: PackageDAG) -> list[list[Package]]: ...

Dependency Validation

CLI Interface

Command-line argument parsing and option handling with comprehensive configuration support.

class Options(Namespace):
    freeze: bool
    python: str
    packages: str
    exclude: str
    reverse: bool
    json: bool
    json_tree: bool
    output_format: str | None
    # ... additional options

def get_options(args: Sequence[str] | None) -> Options: ...
def main(args: Sequence[str] | None = None) -> int | None: ...

CLI Interface

Output Rendering

Renders dependency trees in multiple formats including text, JSON, GraphViz, Mermaid, and freeze formats.

def render(options: Options, tree: PackageDAG) -> None: ...

Output Rendering

Environment Detection

Automatically detects and configures for virtual environments including venv, virtualenv, conda, and Poetry.

def detect_active_interpreter() -> str: ...

Environment Detection

Warning System

Configurable warning and error reporting system with different verbosity levels and output control.

class WarningType(Enum):
    SILENCE = "silence"
    SUPPRESS = "suppress" 
    FAIL = "fail"

class WarningPrinter:
    def __init__(self, warning_type: WarningType = WarningType.SUPPRESS): ...
    def should_warn(self) -> bool: ...
    def print_single_line(self, line: str) -> None: ...

Warning System