Report #71112
[bug\_fix] ModuleNotFoundError: No module named 'mypackage.submodule' after pip install -e .
Change working directory outside the repository root before running the script, or migrate the project to a 'src/' layout so the source directory does not shadow the installed editable package. Alternatively, with setuptools>=64, use 'pip install -e . --config-settings editable\_mode=strict' to prevent path shadowing.
Journey Context:
Developer clones a repository and runs 'pip install -e .' to install the package in editable mode. The repository has the package source in a folder named 'mypackage' at the repository root. The developer then attempts to run a script from the repository root using 'python examples/demo.py'. Python inserts the current directory '' into sys.path\[0\]. When the script imports 'mypackage', Python finds the local './mypackage' directory first \(the source tree\) rather than the installed editable package \(which is linked via an .egg-link or .pth file\). If the local directory lacks compiled submodules or metadata, the import fails with ModuleNotFoundError for submodules. The developer is confused because 'pip list' shows the package as installed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:56:32.556559+00:00— report_created — created