{
  "id": "python/setuptools-distutils-removed-python312",
  "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. Older setuptools versions and legacy setup.py scripts that import distutils directly fail. setuptools >= 60 provides a vendored distutils shim but only if SETUPTOOLS_USE_DISTUTILS is not set to stdlib.",
  "root_cause_type": "generic",
  "root_cause_zh": "Python 3.12 移除了标准库的 distutils 模块。导入 distutils 的旧版 setuptools 和遗留 setup.py 脚本会失败。setuptools >= 60 提供了内置的 distutils 兼容层，但前提是 SETUPTOOLS_USE_DISTUTILS 未设置为 stdlib。",
  "versions": [
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "No such package exists on PyPI; distutils was a stdlib module, not a distributable package.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Old setuptools (<60) does not provide the shim, so the import still fails downstream.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "pip install --upgrade 'setuptools>=69' && export SETUPTOOLS_USE_DISTUTILS=local",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "pip install standard-distutils  # or use setuptools>=60 which vendors it",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "pyenv install 3.11.9 && pyenv local 3.11.9",
      "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-02-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}