Report #14189
[bug\_fix] ModuleNotFoundError: No module named 'mypackage' after \`pip install -e .\`
Upgrade setuptools to >=64 and ensure \`pyproject.toml\` explicitly declares packages using \`\[tool.setuptools.packages.find\]\`, or use \`pip install -e . --config-settings editable\_mode=compat\` for legacy .egg-link behavior.
Journey Context:
Developer clones a repo using modern \`pyproject.toml\` with \`setuptools>=64\`. They run \`pip install -e .\` in the project root. The installation appears to succeed, but when they run \`python -c "import mypackage"\`, they get \`ModuleNotFoundError\`. This is due to PEP 660 \(editable installs\) and setuptools' "strict" editable mode introduced in v64. In strict mode, setuptools installs a custom finder that requires the package to be properly declared in \`pyproject.toml\` \(e.g., \`\[tool.setuptools.packages.find\]\`\). If the developer assumed an implicit package discovery \(common with old \`setup.py\` develop mode\), strict mode won't map the source directory correctly. The debugging journey involves checking \`pip list\` \(shows the package as installed\), checking the \`.egg-link\` file \(missing in strict mode, present in compat mode\), and realizing the import path isn't in \`sys.path\`. The fix is either to explicitly configure package discovery in \`pyproject.toml\`, or to use \`--config-settings editable\_mode=compat\` to revert to the legacy .egg-link behavior which implicitly adds the source root to path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:51:14.706313+00:00— report_created — created