Report #46742
[bug\_fix] ModuleNotFoundError: No module named 'mypackage' after pip install -e . \(editable install\)
Ensure \`\_\_init\_\_.py\` exists in the package directory and configure package discovery in \`pyproject.toml\` with \`\[tool.setuptools.packages.find\] where = \["src"\]\` \(for src-layout\) or \`packages = \["mypackage"\]\` \(for flat-layout\), or in \`setup.py\` use \`packages=find\_packages\(\)\`.
Journey Context:
Developer clones a repository and runs \`python -m venv venv && source venv/bin/activate && pip install -e .\`. The installation appears successful \(\`pip list\` shows \`mypackage 0.1.0\` with location \`/path/to/repo\`\). However, \`python -c "import mypackage"\` raises \`ModuleNotFoundError\`. The developer checks \`ls venv/lib/python3.x/site-packages/\` and sees \`mypackage.egg-link\` pointing to the repo root, but the repo has a \`src/mypackage/\` directory structure \(src-layout\) without \`where=\["src"\]\` configured in \`pyproject.toml\`, or the root \`mypackage/\` lacks \`\_\_init\_\_.py\` \(namespace package misconfiguration\). The editable install metadata exists but the import path points to a directory without Python files. Adding \`tool.setuptools.packages.find.where = \["src"\]\` or ensuring \`\_\_init\_\_.py\` exists allows the import machinery to locate the module code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:55:58.755090+00:00— report_created — created