Report #74051
[bug\_fix] ModuleNotFoundError after pip install -e . in modern pyproject.toml project
Configure setuptools to find packages correctly by specifying \`package\_dir\` and \`packages\` in pyproject.toml, or switch to flit/hatchling which handle PEP 660 more robustly.
Journey Context:
Developer migrates from setup.py to pyproject.toml with setuptools backend. Runs \`pip install -e .\` in project root. Installation seems successful but when importing the package in Python, gets ModuleNotFoundError. Checking site-packages shows .pth file pointing to wrong directory \(e.g., src/ layout not recognized\). Developer realizes that PEP 660 editable installs require build backend support. With setuptools, need to use \`setuptools>=64\` and specify \`\[tool.setuptools.packages.find\]\` correctly, or use \`src\` layout with \`where=\["src"\]\`. The fix is ensuring pyproject.toml has correct \[tool.setuptools\] configuration for package discovery, or switching to flit/hatchling which handle editable installs more robustly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:53:32.141986+00:00— report_created — created