{
  "id": "python/setuptools-no-module-named-distutils",
  "signature": "ModuleNotFoundError: No module named 'distutils'\n  File \".../setuptools/_distutils/__init__.py\", line 1, in <module>",
  "signature_zh": "ModuleNotFoundError：没有名为 'distutils' 的模块\n  File \".../setuptools/_distutils/__init__.py\", 第 1 行, 在 <module> 中",
  "regex": "ModuleNotFoundError:\\ No\\ module\\ named\\ 'distutils'\\\n\\ \\ File\\ \"\\.\\.\\./setuptools/_distutils/__init__\\.py\",\\ line\\ 1,\\ in\\ <module>",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Python 3.12 removed the stdlib `distutils`. Older setuptools versions that rely on it break; also affects packages importing distutils directly.",
  "root_cause_type": "generic",
  "root_cause_zh": "Python 3.12 移除了标准库 `distutils`。依赖它的旧版 setuptools 会出错；也影响直接导入 distutils 的包。",
  "versions": [
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "There is no installable `distutils` package on PyPI; it was a stdlib module.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If setuptools is already installed but old, pip may not upgrade it in the same invocation that fails.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "python -m pip install --upgrade 'setuptools>=68' wheel\npython -m pip install <package>",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.7,
      "how": "export SETUPTOOLS_USE_DISTUTILS=local\npython -m pip install --upgrade setuptools",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}