Report #10102
[bug\_fix] ModuleNotFoundError after pip install -e . in src-layout project
Configure the build backend to recognize the \`src\` directory by setting \`package\_dir=\{"": "src"\}\` in \`setup.py\` or adding \`\[tool.setuptools.packages.find\] where = \["src"\]\` in \`pyproject.toml\`. For modern PEP 660 editable installs, ensure the backend supports src-layout discovery.
Journey Context:
Developer clones a repository with a \`src/\` directory structure \(\`src/mypackage/\_\_init\_\_.py\`\). They create a virtual environment and run \`pip install -e .\` from the repository root. The installation completes successfully, creating an \`.egg-link\` file. However, when they run \`python -c "import mypackage"\`, they receive \`ModuleNotFoundError: No module named 'mypackage'\`. Inspecting \`site-packages/mypackage.egg-link\`, they see it points to the repository root, not the \`src/\` subdirectory where the package actually lives. The developer realizes that \`setuptools\` defaults to looking for packages in the root directory and must be explicitly configured to look in \`src/\` using \`package\_dir\` or modern \`pyproject.toml\` configuration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:49:12.283421+00:00— report_created — created