Registry / devops / modulegraph2

modulegraph2

JSON →
library2.3pypypi✓ verified 84d ago

A library for computing a module import dependency graph for Python projects (version 2.3). Released irregularly; currently supports Python >=3.10.

pip install modulegraph2
INSTALL
IMPORT
SIG · MODULEGRAPH2
M
modulegraph2
devopspythonv2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

ModuleGraph
from modulegraph2 import ModuleGraph
from modulegraph import ModuleGraph
modulegraph is a different legacy library; use modulegraph2 for Python 3.10+
find_modules
from modulegraph2 import find_modules
Alternative entry point; used in official documentation

Creates a module graph for 'my_module' in the current directory and prints all nodes.

from modulegraph2 import ModuleGraph mg = ModuleGraph(path=['.']) mg.import_graph('my_module') for node in mg.nodes(): print(node.identifier, type(node).__name__)
Debug
Known issues
gotchaModuleGraph by default only resolves imports from the current working directory; to include standard library and installed packages, you must specify include_stdlib=True and include_site_packages=True.
fix
mg = ModuleGraph(path=['.'], include_stdlib=True, include_site_packages=True)
affects: all versions in 2.x
deprecatedPython 3.10 minimum; earlier versions are unsupported and will raise errors.
fix
Ensure Python interpreter version is >= 3.10.
affects: 2.x
gotchaThe 'path' parameter must be a list of directory strings; passing a single string (e.g., path='.') will cause a TypeError.
fix
mg = ModuleGraph(path=['.'])
affects: all versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'modulegraph'
Tried to import the legacy modulegraph instead of modulegraph2.
fix
Install modulegraph2 and use 'from modulegraph2 import ModuleGraph'.
TypeError: expected str, bytes or os.PathLike object, not list
Passing a list to path that contains non-string items or wrong arguments.
fix
Ensure path is a list of strings: mg = ModuleGraph(path=['/path/to/project'])
AttributeError: module 'modulegraph2' has no attribute 'ModuleGraph'
Installed version is too old or wrong import path.
fix
Upgrade: pip install --upgrade modulegraph2. Then use 'from modulegraph2 import ModuleGraph'.
Upgrade
Version history
2.3latest on PyPI · released Nov 23, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
modulegraph2 — pip install modulegraph2 · libregistry