Report #71129
[bug\_fix] ModuleNotFoundError for namespace package subpackage \(e.g. zope.interface\) despite installation
Remove any stale '\_\_init\_\_.py' file from the namespace package directory \(e.g., 'zope/\_\_init\_\_.py'\) and delete associated '\_\_pycache\_\_' directories. Ensure installed packages use 'find\_namespace\_packages\(\)' in their setup configuration and omit '\_\_init\_\_.py' from the namespace root.
Journey Context:
Developer installs 'zope.interface' using pip. The installation reports success. However, running 'import zope.interface' raises 'ModuleNotFoundError: No module named 'zope'' or 'No module named 'zope.interface''. Inspecting 'site-packages' reveals that 'zope.interface-xxx.dist-info' exists and 'zope/interface/' exists, but there is an old file 'zope/\_\_init\_\_.py' \(possibly from a legacy installation\). Because 'zope/\_\_init\_\_.py' exists, Python treats 'zope' as a regular package, not a namespace package \(PEP 420\). It stops searching the rest of sys.path for other 'zope' contributions, hiding the 'interface' subpackage installed elsewhere.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:58:15.310765+00:00— report_created — created