Report #103742
[bug\_fix] ModuleNotFoundError after pip install -e . in a namespace package layout
For PEP 420 namespace packages, ensure the namespace directories \(e.g. \`company/\`\) contain no \`\_\_init\_\_.py\`. Use a modern pyproject.toml with setuptools or another backend that explicitly supports editable namespace packages, and avoid legacy \`setup.py develop\` with implicit namespace layouts.
Journey Context:
You have a repo structured \`src/company/product/\_\_init\_\_.py\` and \`src/company/plugin/\_\_init\_\_.py\`. After \`pip install -e .\`, imports of \`company.plugin\` fail. You add an \`\_\_init\_\_.py\` to \`company/\` and now imports work for one package but break for another because the two namespace portions are installed from different repositories. The confusion is that regular packages need \`\_\_init\_\_.py\`, but PEP 420 namespace packages explicitly must not have one at the namespace level; the namespace is formed by aggregating multiple directories on sys.path that share the same parent name. The fix is to remove the stray \`\_\_init\_\_.py\` from the namespace root and ensure the build backend declares namespace support, so editable installation exposes the namespace portion correctly without claiming ownership of the whole namespace.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:37:40.879569+00:00— report_created — created