Report #86858
[bug\_fix] ModuleNotFoundError after \`pip install -e .\` with src-layout project
Add \`package\_dir=\{"": "src"\}\` in setup.py or \`\[tool.setuptools.packages.find\] where = \["src"\]\` in pyproject.toml. Root cause: Editable installs symlink the project root; without \`package\_dir\`, setuptools does not map the \`src\` directory onto \`sys.path\`, so the package is not importable despite the install appearing successful.
Journey Context:
You clone a repository using the src-layout \(\`src/mypackage/\`\). You run \`pip install -e .\` and see 'Successfully installed mypackage'. You open Python and \`import mypackage\`, getting \`ModuleNotFoundError\`. You check \`pip list\` and \`mypackage\` is listed. Inspecting \`sys.path\`, you see your project root is there, but not the \`src/\` directory. You realize setuptools is looking for packages in the repository root instead of \`src/\`. After adding \`package\_dir=\{"": "src"\}\` to setup.py \(or the equivalent pyproject.toml configuration for setuptools\) and reinstalling, the editable install correctly places \`src\` on the path and the import succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:22:41.151342+00:00— report_created — created