pyan3
Generate approximate call graphs for Python programs
What it is and what it does
Pyan3 reads Python source files and builds a directed graph of how functions, classes, and modules relate to each other through calls and definitions. Unlike runtime profilers, it performs static analysis by examining code structure rather than executing it, making it useful for understanding architecture without running the code. The tool outputs graphs in multiple formats—GraphViz DOT, yEd, SVG, HTML, or plain text—and supports filtering by depth, direction, and import cycles. It also performs module-level dependency analysis to detect circular imports.
The package was recently revived in February 2026 with support for modern Python syntax (walrus operators, match statements, async with, type aliases) across Python 3.10–3.14. It includes a comprehensive test suite and offers both a command-line interface and a Python API for programmatic use. The single runtime dependency is jinja2, keeping the install footprint minimal.
Use it for:
- Visualize call graphs for code review or documentation by generating SVG diagrams of function relationships.
- Detect circular import dependencies at the module level to identify architectural problems.
- Generate plain-text call graphs to feed into coding AI agents or documentation systems.
- Analyze codebase structure without executing it, useful for security audits or understanding unfamiliar projects.
- Control graph detail with depth filtering to create high-level architecture overviews or drill down to specific functions.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pyan3 performs static analysis on Python source code to generate call graphs showing how functions, classes, and modules use each other, with output to GraphViz, yEd, or plain text.
Yes, if you need static call-graph visualization or dependency analysis. The package is actively maintained, supports current Python versions, has low install friction, and offers both CLI and API modes. The copyleft GPL-2.0-or-later license is a consideration only if you plan to redistribute derivative code commercially. No known vulnerabilities.
Install
pyan3 on PyPI
pip
pip install pyan3uv
uv add pyan3poetry
poetry add pyan3Installing pyan3
Before you install
Low install friction with a single runtime dependency (jinja2). The project is actively maintained as of February 2026, recently revived with modernized analyzer and comprehensive test coverage, supporting Python 3.10–3.14.
License in practice
Licensed under GPL-2.0-or-later (copyleft). You may use and modify the package freely, but any derivative work distributed must also be open-source under a compatible GPL license.
Quickstart
pip install pyan3
pyan3 src/ --dot --colored --no-defines --concentrate --file output.dot
dot -Tsvg output.dot -o output.svg
Requires Python 3.10 or later. GraphViz must be installed separately to render DOT output to SVG/PNG.
Verify before relying
- Whether the 200+ test suite and 91% branch coverage claim applies to the current 2.6.2 release or is aspirational.
- Performance characteristics on large codebases (e.g., thousands of files or deeply nested packages).
- Accuracy of static analysis for dynamic imports, eval, or __import__ patterns.
Package facts
| License | GPL-2.0-or-later (copyleft) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — jinja2 |
| Maintenance | actively maintained — 31 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 204,166/month — #9,615 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyan3-2.6.2-py3-none-any.whl
Keywords: call-graph, static-code-analysis, code-visualization, dependency-analysis
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
import-depsAnalyzes Python module imports statically using…
permissive · top 5,000 on PyPI
pydepsVisualizes Python module dependencies as graphs…
permissive · top 15,000 on PyPI
graphvizGenerates DOT language source code for graph…
permissive · top 1,000 on PyPI
objgraphObjgraph lets you visualize and explore Python…
permissive · top 5,000 on PyPI
modulegraphmodulegraph analyzes Python module dependencies…
permissive · top 15,000 on PyPI
pygraphvizPyGraphviz provides a Python interface to…
permissive · top 5,000 on PyPI
ipydagred3ipydagred3 is an ipywidgets library for…
permissive · top 15,000 on PyPI
pydot-ngpydot-ng provides a Python interface to…
permissive · top 15,000 on PyPI
GvGenGvGen generates Graphviz dot files…
permissive · top 15,000 on PyPI
grimpGrimp builds a queryable graph of Python…
permissive · top 5,000 on PyPI