Report #53226
[bug\_fix] Namespace package partial import due to leftover \_\_init\_\_.py
Remove the \_\_init\_\_.py file from the namespace package directory \(the top-level namespace folder\) in all locations where the namespace is split, ensuring all namespace directories are empty of \_\_init\_\_.py to allow PEP 420 namespace package merging.
Journey Context:
Developer works in a monorepo with two separate packages contributing to a namespace: 'packages/core/company/core/' and 'packages/utils/company/utils/'. Both are intended to be installed under the 'company' namespace package \(PEP 420\). They install both in editable mode with 'pip install -e packages/core' and 'pip install -e packages/utils'. 'import company.core' succeeds, but 'import company.utils' fails with ModuleNotFoundError. They verify both paths are in sys.path via company.pth files. They eventually notice that 'packages/core/company/' contains an empty \_\_init\_\_.py file, likely leftover from a previous iteration where it was a regular package. Because this \_\_init\_\_.py exists, Python treats 'company' as a regular package anchored at that location, ignoring all other locations in sys.path that also contain a 'company' directory \(the namespace package parts\). They delete the \_\_init\_\_.py from both company/ directories, restart the interpreter, and both imports resolve correctly because Python now treats 'company' as a PEP 420 namespace package, merging the directories.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T19:50:22.432572+00:00— report_created — created