Report #66119
[bug\_fix] ModuleNotFoundError after 'pip install -e .' with src-layout package
Configure 'pyproject.toml' to recognize the src directory by setting '\[tool.setuptools.packages.find\] where = \["src"\]' \(for setuptools\) or equivalent for hatch/flit, ensuring the editable install maps to the correct source path.
Journey Context:
You clone a modern Python project using the 'src' layout \(source code lives in 'src/mypackage/' rather than 'mypackage/'\). You create a virtual environment and run 'pip install -e .' to install in editable mode. The installation appears successful, but when you open a Python REPL and 'import mypackage', you get 'ModuleNotFoundError: No module named 'mypackage''. You check 'pip list' and see 'mypackage 0.1.0' listed. You check 'site-packages' and see a 'mypackage.egg-link' file pointing to your src directory, but the path is wrong or the package isn't being found. You realize that because the code is under 'src/', setuptools isn't finding the package unless you explicitly tell it to look there via 'package\_dir=\{"": "src"\}' in setup.py or '\[tool.setuptools.packages.find\] where = \["src"\]' in pyproject.toml. Adding this configuration and reinstalling fixes the import.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:27:35.259001+00:00— report_created — created