Skip to main content

Visualise the import graph of any Python project or file

Project description

PyPI version GitHub license

impgraph

Visualise the import dependency graph of any Python project or file.

  • AST-based parsing — accurate, handles all import forms
  • Pure-Python rendering via matplotlib — no system Graphviz required
  • Interactive HTML output via pyvis — hover, drag, zoom
  • Cycle detection and per-module metrics (in/out-degree, PageRank)
  • Rich terminal output with progress spinner and tables

Installation

pip install impgraph

No system dependencies required — rendering is done entirely in Python via matplotlib.

To use the pygraphviz backend (requires system Graphviz + brew install graphviz):

pip install "impgraph[pygraphviz]"

Quick start

# Print a table of modules and imports (no rendering needed)
impgraph info path/to/project

# Render a PNG dependency graph
impgraph graph path/to/project -o graph.png

# Also write an interactive HTML graph
impgraph graph path/to/project -o graph.png --html

# Show import cycles and per-module metrics
impgraph graph path/to/project --cycles --metrics

Commands

impgraph graph <path>

Render the import dependency graph for a file or directory.

Flag Default Description
-o / --output graph.png Output file path
-f / --format png Output format: png, svg, pdf, …
-l / --layout dot Graphviz layout: dot, neato, fdp, circo, twopi, …
-j / --json Also write import data as JSON
--html / -H off Also write an interactive HTML graph
--stdlib off Include standard library imports
--no-relative off Exclude relative imports
--pygraphviz off Use pygraphviz backend instead of pure-Python graphviz
--cycles off Print detected import cycles
--metrics off Print per-module in/out-degree and PageRank table

impgraph info <path>

Print a Rich table of every module and its imports. No Graphviz required — useful in CI.

Flag Default Description
--stdlib off Include standard library imports

Visual legend

Colour Meaning
Blue box Local module (part of the analysed project)
Green ellipse External package

Notes

  • Directories automatically excluded: .venv, venv, __pycache__, .git, dist, build, .mypy_cache, .ruff_cache, node_modules, .vscode, .idea
  • Standard library detection uses sys.stdlib_module_names — always accurate for the running interpreter
  • A single file can be passed instead of a directory

Development

uv sync --all-extras
uv run pytest --cov
uv run mypy src/
uv run ruff check src/ tests/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

impgraph-2.0.0.tar.gz (93.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

impgraph-2.0.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file impgraph-2.0.0.tar.gz.

File metadata

  • Download URL: impgraph-2.0.0.tar.gz
  • Upload date:
  • Size: 93.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for impgraph-2.0.0.tar.gz
Algorithm Hash digest
SHA256 937820242bd6f5ff05f5cf97d2f18dfe3ab0c6fa2364a01763cbeb315cd7d0ed
MD5 4c86ac59e6054ea802695e95d1315931
BLAKE2b-256 dbbd1c5aa07071dd016849ba4b9d174a9d987d12637ac8cc1d5b775ca74faf49

See more details on using hashes here.

File details

Details for the file impgraph-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: impgraph-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for impgraph-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fffea51fe1e2454ecd5d9e6446b63fa61ee80969cd88326ed0068ea0f55e6d7c
MD5 f89d0def39e2e0b89001df9479bbead6
BLAKE2b-256 51c8fa39073c0c80be5d0e41de4c1ad86fc4954408f766b6938c9fa9046e7319

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page