Report #56007
[bug\_fix] ModuleNotFoundError after pip install -e . \(Editable install without build backend\)
Add a \`\[build-system\]\` section to \`pyproject.toml\` specifying the build backend, e.g.: \`\[build-system\] requires = \["setuptools>=61.0"\] build-backend = "setuptools.build\_meta"\`. Alternatively, ensure \`setup.py\` is present and contains \`setup\(\)\` call for legacy mode, or use \`pip install -e . --config-settings editable\_mode=compat\` \(setuptools specific\). Root cause: Since PEP 660 \(pip 21.0\+\), editable installs require a build backend to generate \`.pth\` files or import hooks. If \`pyproject.toml\` exists but lacks \`\[build-system\]\`, pip may fail to set up the path correctly, leaving the package unimportable despite \`pip list\` showing it.
Journey Context:
Developer modernizes a project by moving metadata from \`setup.py\` to \`pyproject.toml\` following PEP 621. They add \`\[project\]\` with \`name\` and \`dependencies\`, but forget the \`\[build-system\]\` table. They run \`pip install -e .\` which reports \`Successfully installed mypackage\`. However, \`python -c "import mypackage"\` immediately raises \`ModuleNotFoundError: No module named 'mypackage'\`. They check \`pip show mypackage\` which shows the location as the source directory, but \`site-packages\` lacks a \`.pth\` file. They realize that without a build-system declaration, pip doesn't know how to create an editable install hook. Adding \`\[build-system\]\` with \`requires = \["setuptools>=61.0"\]\` and \`build-backend = "setuptools.build\_meta"\` causes pip to generate a \`mypackage.pth\` file in site-packages pointing to the source, fixing the import.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T00:30:12.344919+00:00— report_created — created