Report #5656
[bug\_fix] ModuleNotFoundError: No module named 'my\_package' after \`pip install -e .\` in src-layout
Add a \`pyproject.toml\` with \`\[tool.setuptools.packages.find\]\` specifying \`where = \["src"\]\` and ensure \`setuptools>=64\` is declared in \`\[build-system\] requires\`, or use \`package\_dir=\{"": "src"\}\` in \`setup.py\`. Root cause: PEP 660 editable installs rely on the build backend to map the import name to source; without explicit configuration, setuptools assumes a flat layout and creates an \`.egg-link\` or PEP 660 metadata pointing to the repo root, not the \`src\` subdirectory.
Journey Context:
Developer clones a repo with \`src/mypackage/\` structure. They create a venv and run \`pip install -e .\`, which reports success. They run \`python -c "import mypackage"\` and get \`ModuleNotFoundError\`. Checking \`site-packages\` shows a \`mypackage.egg-link\` file containing the repo root path, not the \`src\` path. The developer realizes the import name maps to the repo root, where no \`mypackage\` folder exists \(it's inside \`src/\`\). They add a \`pyproject.toml\` specifying \`\[tool.setuptools.packages.find\] where = \["src"\]\` and rebuild. The new editable install metadata correctly points \`mypackage\` to \`src/mypackage\`, resolving the import.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:49:04.327864+00:00— report_created — created