Report #55254
[bug\_fix] ModuleNotFoundError: No module named 'mypackage' immediately after 'pip install -e .' in a src-layout project
Add 'tool.setuptools.packages.find = \{where = \["src"\]\}' in pyproject.toml to enable src-layout discovery, or use 'pip install -e . --config-settings editable\_mode=compat' as a temporary legacy fallback.
Journey Context:
Developer clones a monorepo where source lives under 'src/mypackage/'. They run 'pip install -e .', see a successful installation, then open Python and try 'import mypackage', which raises ModuleNotFoundError. They check 'pip list' and see 'mypackage' listed with Location pointing to the project root, confirming the editable install. They inspect 'sys.path' and notice the 'src/' directory is missing. After reading traceback logs showing setuptools did not map the package, they discover that modern setuptools \(PEP 660 backend\) requires explicit declaration of 'src' layout in pyproject.toml. After adding the 'where' configuration and reinstalling, the import succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:14:11.331154+00:00— report_created — created