Report #74455
[bug\_fix] ModuleNotFoundError after 'pip install .' where 'pip install -e .' worked fine \(Missing packages due to lack of find\_packages or src layout misconfiguration\)
Configure 'setuptools.packages.find\_packages\(\)' in setup.py or '\[tool.setuptools.packages.find\]' in pyproject.toml to discover subpackages, or adopt a 'src/' layout with proper 'package\_dir' configuration. The root cause is that 'pip install -e .' adds the source directory to sys.path, masking the fact that the package isn't being copied into site-packages.
Journey Context:
A developer creates a new project with a directory 'myproject/' containing 'foo.py' and 'bar.py', and a 'setup.py' that only specifies 'py\_modules' or has no package discovery. They run 'pip install -e .' to develop. Everything works because editable mode inserts the project root into sys.path \(via easy-install.pth\). They push to CI, which runs 'pip install .' and then 'pytest'. Tests fail with 'ModuleNotFoundError: No module named myproject'. The developer investigates 'pip show myproject', sees it installed, but checks 'site-packages' and finds only a 'myproject-0.1.0.dist-info' folder, no 'myproject/' package directory. They realize 'setup.py' lacks 'packages=find\_packages\(\)'. Adding this and reinstalling fixes it because now setuptools copies the package into site-packages.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:34:09.517450+00:00— report_created — created