Report #78560
[bug\_fix] ModuleNotFoundError: No module named 'mypackage' after pip install -e .
Configure the package directory mapping in \`pyproject.toml\` by setting \`\[tool.setuptools.packages.find\] where = \["src"\]\` \(for src-layout\) or \`package\_dir = \{"": "src"\}\` in \`setup.py\`. Then reinstall editable. This tells setuptools to look for packages in the \`src\` directory rather than the repository root.
Journey Context:
A developer clones a repository adopting the src-layout \(\`repo/src/mypackage/\_\_init\_\_.py\`\). They create a venv, activate it, and run \`pip install -e .\` from the repo root. The command succeeds and \`pip list\` shows \`mypackage\`. However, opening a Python REPL and typing \`import mypackage\` raises \`ModuleNotFoundError\`. The developer verifies \`sys.path\` and inspects \`venv/lib/python3.x/site-packages/\`, finding a \`mypackage.egg-link\` file containing a path pointing to the repository root \(where \`mypackage\` does not exist; it lives in \`src/\`\). The developer realizes that setuptools, by default, searches for packages in the root directory. Because the actual package is nested under \`src/\`, the editable install creates a link to the wrong location. After adding the \`package\_dir\` configuration to map the source root, the egg-link correctly points to \`repo/src\`, and the import succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:27:35.649281+00:00— report_created — created