{
  "id": "python/setuptools-missing-distutils",
  "signature": "ModuleNotFoundError: No module named 'distutils'",
  "signature_zh": "模块未找到错误：没有名为 'distutils' 的模块",
  "regex": "ModuleNotFoundError:\\ No\\ module\\ named\\ 'distutils'",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Python 3.12 removed the stdlib distutils module. Packages or setup.py scripts that import distutils (directly or via old setuptools) fail unless setuptools provides the distutils shim.",
  "root_cause_type": "generic",
  "root_cause_zh": "Python 3.12 移除了标准库 distutils 模块。直接导入 distutils（或经由旧版 setuptools）的包或 setup.py 会失败，除非 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": "distutils was a stdlib module, never a PyPI package; the install fails.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "No such distribution exists.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Very old setuptools is incompatible with Python 3.12 in other ways.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "pip install --upgrade 'setuptools>=68'\n# setuptools injects a distutils shim via SETUPTOOLS_USE_DISTUTILS=local",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.7,
      "how": "export SETUPTOOLS_USE_DISTUTILS=local\npip install <pkg>",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.78,
      "how": "pyenv install 3.11.9 && pyenv local 3.11.9\npip install <pkg>",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}