Report #62021
[bug\_fix] ModuleNotFoundError after pip install -e . with src-layout package
Configure the build backend to recognize the src directory by setting \`\[tool.setuptools.packages.find\]\` with \`where = \["src"\]\` in pyproject.toml, or use \`pip install -e ./src\` for simple cases, ensuring the package is discoverable during editable installs.
Journey Context:
You clone a modern Python repository using the 'src-layout' \(package source is in \`src/mypackage/\`\). You create a venv and run \`pip install -e .\` to install in editable mode for development. The install appears to succeed. You open a Python REPL and \`import mypackage\`, getting \`ModuleNotFoundError: No module named 'mypackage'\`. You check \`pip list\` and see \`mypackage\` listed with version 0.0.0. You check \`site-packages\` and see \`mypackage.egg-link\` pointing to the repo root, not the src directory. You realize that \`setup.py\` or \`pyproject.toml\` lacks configuration to tell setuptools that the package is under \`src/\`, so it's creating an egg-link to the root where there's no importable package. You edit \`pyproject.toml\` to add \`\[tool.setuptools.packages.find\]\` with \`where = \["src"\]\`, reinstall with \`pip install -e .\`, and now the egg-link 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-20T10:35:16.094035+00:00— report_created — created