Skip to content

metapathology

metapathology is a stdlib-only diagnostic tool for CPython's import system. It helps answer three questions:

  • Which finder located each imported module?
  • Where did code change sys.meta_path or sys.path_hooks?
  • Which modules were found without going through the normal sys.path search?

It was created to investigate conflicts where one import customization prevents another from seeing a module. The monitor only observes: it never returns a module spec or loads a module itself.

Start here

Run a script with the same Python interpreter and environment as the target:

python -m metapathology myscript.py --my-args

Or run an importable module:

python -m metapathology -m pytest tests/

The target runs normally and a diagnostic report is written to standard error when it finishes. See Using metapathology for library integration and lifecycle control.

Guide

metapathology supports CPython 3.10 and newer and has no runtime dependencies.