Report #57628
[bug\_fix] ModuleNotFoundError: No module named 'mypackage' immediately after successful 'pip install -e .'
Configure setuptools to look for packages in the 'src' directory by setting \[tool.setuptools.packages.find\] where = \['src'\] in pyproject.toml, or in setup.py use packages=find\_packages\(where='src'\) and package\_dir=\{'': 'src'\}. Then reinstall with 'pip install -e .'. The root cause is that the editable install creates a .pth file pointing to the project root, but the actual package code is in src/, so Python's import system cannot find 'mypackage' at the root level.
Journey Context:
Developer clones a repository with a 'src/mypackage/' directory structure \(src layout\). They run 'pip install -e .' successfully. Importing 'mypackage' fails with ModuleNotFoundError. They check site-packages and see an .egg-link pointing to src/, but the company directory isn't recognized. They realize that because there's no \_\_init\_\_.py in company/, setuptools.find\_packages\(\) didn't discover it. Switching to find\_namespace\_packages\(\) fixes it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T03:12:58.861212+00:00— report_created — created