Python Import Failures

Diagnose Python imports that behave differently by directory, tool or machine by asking the interpreter instead of guessing at paths: print where a module resolved with m.__file__ and m.__spec__, read python -m site, rerun under python -I to drop the cwd and user site, and pip show -f for what a distribution contains. Sorts the cause into five (shadowing, a file run instead of a module, a package missing from the wheel, a namespace package, a stale editable install) and proves packaging bugs from the built wheel in a fresh venv. Use for "ModuleNotFoundError only in CI", "works with python -m but not as a script", "cannot import name (circular import)", "pytest cannot find my package". Not for restructuring modules on purpose (refactoring), version solving (dependency-resolution-conflict), compiled wheel failures (python-native-wheel-failures), general cause-finding (debugging).

greenblacked Updated
The twenty-nine plugins: coding, family, gamedev, operations, delivery, security, manager, personal, career, design, llm, data, techdocs, assurance, client-apps

File contents

greenblacked/AI commit f27ef72647

Frequently asked questions

npx get-skill add greenblacked/python-import-failures