Report #93638
[bug\_fix] ModuleNotFoundError: No module named 'mypackage' after pip install -e . in src-layout
Use a build backend that supports PEP 660 editable installs \(setuptools>=64 with pyproject.toml configuration\), or manually add \`PYTHONPATH=src\` when running Python.
Journey Context:
Developer clones a modern Python project using \`src/mypackage/\` layout. They run \`pip install -e .\`. Installation appears successful. However, \`python -c "import mypackage"\` fails with ModuleNotFoundError. Checking \`python -m site\` shows the editable install path points to the project root, not the src directory, or the .pth file created by the legacy editable install points to the wrong place. Root cause: Legacy setuptools editable installs \(setup.py develop\) don't handle src-layout correctly; they add the root to path, not the src folder. Modern PEP 660 editable installs use import hooks that correctly map the package name to the src directory. Upgrading setuptools and configuring \`package-dir = \{"": "src"\}\` in pyproject.toml fixes the mapping.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:45:28.255494+00:00— report_created — created