python
module_error
ai_generated
partial
ImportError: cannot import name 'foo' from partially initialized module 'mypkg' (most likely due to a circular import)
ID: python/setuptools-namespace-package-conflict
80%Fix Rate
82%Confidence
0Evidence
2025-08-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
Root Cause
Namespace package layout misconfigured via setup.py/pyproject.toml, causing circular or partial imports.
generic中文
通过 setup.py/pyproject.toml 配置的命名空间包布局错误,导致循环或部分导入。
Workarounds
-
85% success
from setuptools import setup, find_namespace_packages setup(name='mypkg', packages=find_namespace_packages(include=['mypkg.*']))
-
90% success
[tool.setuptools.packages.find] namespaces = true include = ["mypkg*"]
Dead Ends
Common approaches that don't work:
-
70% fail
Breaks the intended namespace-package semantics and can cause duplicate module paths.
-
60% fail
Masks the layout issue; import may still fail elsewhere.