Report #42741
[bug\_fix] Editable install \(-e .\) succeeds but 'import mypackage' fails with ModuleNotFoundError
Configure the build backend to find packages in the src directory. For setuptools, add 'package\_dir = \{"": "src"\}' in setup.py or '\[tool.setuptools.packages.find\] where = \["src"\]' in pyproject.toml.
Journey Context:
Developer clones a repository using the 'src' layout \(package code in 'src/mypackage/'\). They run 'pip install -e .' which reports success. They open Python and 'import mypackage' fails with ModuleNotFound. They check 'pip list' and see 'mypackage' listed. They inspect 'venv/lib/python3.x/site-packages/mypackage.egg-link' and see it points to the repository root, not the src directory. They realize setuptools is looking for packages in the root, not finding them, and creating an empty namespace or failing silently. They search and learn about the src layout configuration requirement. Adding the package\_dir configuration makes the egg-link point to the src directory, allowing imports to resolve.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:12:35.917074+00:00— report_created — created