Registry / devops / modulegraph

modulegraph

JSON →
library0.19.7pypypi✓ verified 90d ago

Python module dependency analysis tool that builds a directed graph of module dependencies. Current version 0.19.7, maintained by Ronald Oussoren. Releases are irregular, primarily as needed.

pip install modulegraph
INSTALL
IMPORT
SIG · MODULEGRAPH
M
modulegraph
devopspythonv0.19.7
Install
1.9s avg
Import
—
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.19.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.2MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.9s · import 0.000s · 19MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

modulegraph
✓ import modulegraph
The main module is importable directly.
ModuleGraph
✓ from modulegraph import ModuleGraph
✗ from modulegraph.modulegraph import ModuleGraph
Do not use the dotted path; simply import from modulegraph.

Analyze dependencies of a Python script.

from modulegraph import ModuleGraph g = ModuleGraph() g.run_script('example.py') for node in g.nodes(): print(node.identifier, node.filename)
Debug
Known issues
breakingIn modulegraph 0.18 and later, the internal node attributes changed. Accessing 'type' or 'filename' directly on a node may break if you relied on old values.
fix
Use node.identifier and node.filename (now always a str) instead of node.type or node.filename (could be None).
affects: >=0.18.0
deprecatedThe 'find_modules' method is deprecated in favor of 'run_script' and 'import_hook'.
fix
Replace calls to g.find_modules('script.py') with g.run_script('script.py').
affects: >=0.17.0
gotchaModuleGraph does not automatically re-analyze if the script's imports change. You must create a new graph instance for a fresh analysis.
fix
Always instantiate a new ModuleGraph() for each independent dependency analysis.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'modulegraph'
Modulegraph not installed in the current Python environment.
fix
Run 'pip install modulegraph' in your environment.
AttributeError: 'ModuleGraph' object has no attribute 'find_modules'
Using deprecated API removed since version 0.18.
fix
Use 'run_script' instead: g.run_script('your_script.py').
TypeError: 'NoneType' object is not subscriptable (when accessing node.filename)
Node may not have a filename (e.g., built-in modules). In older versions, filename could be None.
fix
Check if node.filename is not None before using it, or use getattr(node, 'filename', '').
Upgrade
Version history
0.19.7latest on PyPI · released Nov 22, 2025
Audit
Dependencies
setuptoolsrequiredRequired for pkg_resources checks during dependency resolution
Agent activity
8 hits · last 30 days
node
8
Resources
modulegraph — pip install modulegraph · libregistry