Report #14000
[bug\_fix] ModuleNotFoundError after \`pip install -e .\` in src-layout project
Configure \`tool.setuptools.packages.find\` in \`pyproject.toml\` with \`where = \["src"\]\` \(or use \`setup.py\` with \`package\_dir=\{"": "src"\}\`\). Without this, setuptools looks for packages in the root directory instead of the \`src/\` directory, so the editable install creates an empty metadata link and imports fail because the package isn't on sys.path.
Journey Context:
You're modernizing a project to use src-layout \(separating source from project root\). You move \`mypackage/\` into \`src/mypackage/\` and create a \`pyproject.toml\` with \`\[build-system\] requires = \["setuptools", "wheel"\]\`. You run \`pip install -e .\` from the project root and it succeeds with "Successfully installed mypackage-1.0.0". You open a Python shell and \`import mypackage\` gets \`ModuleNotFoundError: No module named 'mypackage'\`. You check \`pip show mypackage\` and it points to your source directory, but \`site-packages\` has only a \`.pth\` file. You realize that setuptools didn't find any packages because it's looking in the root, not in \`src/\`. You check the setuptools docs and find you need \`\[tool.setuptools.packages.find\] where = \["src"\]\`. You add that, reinstall with \`pip install -e .\`, and now the \`.pth\` file correctly points 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-16T20:21:17.310142+00:00— report_created — created