Report #58198
[bug\_fix] ModuleNotFoundError for package in src-layout after pip install -e .
Configure setuptools to discover packages in the \`src\` directory by adding \`\[tool.setuptools.packages.find\]\` with \`where = \["src"\]\` in \`pyproject.toml\` \(or \`package\_dir=\{"": "src"\}\` in \`setup.py\`\), then reinstall with \`pip install -e .\`.
Journey Context:
A developer clones a modern Python project using the src-layout: source code lives in \`src/mypackage/\` rather than \`mypackage/\` at the project root. They see a \`pyproject.toml\` with build-system requirements. They run \`pip install -e .\` which succeeds. They open a Python REPL and try \`import mypackage\`, getting \`ModuleNotFoundError\`. They check \`site-packages\` and see \`mypackage.egg-link\` pointing to the project root directory, not the \`src\` subdirectory. Since Python looks in the project root for \`mypackage\`, it finds nothing \(the code is in \`src/mypackage\`\). They realize that setuptools by default searches for packages in the root, but src-layout requires explicitly telling it to look in \`src/\`. After adding the \`where = \["src"\]\` configuration and reinstalling, the egg-link points correctly to \`src/\` and imports work.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:10:42.766388+00:00— report_created — created