{
  "id": "python/setuptools-namespace-package-conflict",
  "signature": "ImportError: cannot import name 'foo' from partially initialized module 'mypkg' (most likely due to a circular import)",
  "signature_zh": "ImportError: 无法从部分初始化的模块 'mypkg' 导入名称 'foo'（很可能是由于循环导入）",
  "regex": "ImportError:\\ cannot\\ import\\ name\\ 'foo'\\ from\\ partially\\ initialized\\ module\\ 'mypkg'\\ \\(most\\ likely\\ due\\ to\\ a\\ circular\\ import\\)",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Namespace package layout misconfigured via setup.py/pyproject.toml, causing circular or partial imports.",
  "root_cause_type": "generic",
  "root_cause_zh": "通过 setup.py/pyproject.toml 配置的命名空间包布局错误，导致循环或部分导入。",
  "versions": [
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Breaks the intended namespace-package semantics and can cause duplicate module paths.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Masks the layout issue; import may still fail elsewhere.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "from setuptools import setup, find_namespace_packages\nsetup(name='mypkg', packages=find_namespace_packages(include=['mypkg.*']))",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "[tool.setuptools.packages.find]\nnamespaces = true\ninclude = [\"mypkg*\"]",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2025-08-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}