{
  "id": "python/setuptools-cannot-import-setup-from-setuptools",
  "signature": "ImportError: cannot import name 'setup' from 'setuptools' (/path/to/setuptools/__init__.py)",
  "signature_zh": "导入错误：无法从 'setuptools' 导入名称 'setup'（/path/to/setuptools/__init__.py）",
  "regex": "ImportError:\\ cannot\\ import\\ name\\ 'setup'\\ from\\ 'setuptools'\\ \\(/path/to/setuptools/__init__\\.py\\)",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "A local file named setuptools.py shadows the package, or the installed setuptools is corrupted/incompletely uninstalled, leaving a partial __init__.py without setup.",
  "root_cause_type": "generic",
  "root_cause_zh": "本地存在名为 setuptools.py 的文件遮蔽了包，或已安装的 setuptools 损坏/卸载不完整，留下缺少 setup 的部分 __init__.py。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "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"
    },
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If a local setuptools.py shadows the package, upgrade doesn't help.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "It's a build-time dependency, not a runtime one.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Destroys the environment; you'll need to rebuild it.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "find . -maxdepth 3 -name 'setuptools.py' -print\n# rename/delete it\nmv ./setuptools.py ./setuptools.py.bak",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "python -m venv .venv && . .venv/bin/activate\npip install --upgrade --force-reinstall setuptools",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "python -c \"import setuptools, inspect; print(setuptools.__file__); print(hasattr(setuptools, 'setup'))\"",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-29",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}