{
  "id": "python/setup-py-deprecated-distutils-removed",
  "signature": "ModuleNotFoundError: No module named 'distutils'",
  "signature_zh": "ModuleNotFoundError：没有名为 'distutils' 的模块",
  "regex": "ModuleNotFoundError:\\ No\\ module\\ named\\ 'distutils'",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Python 3.12 removed the stdlib distutils module. Legacy setup.py scripts or old setuptools versions import distutils directly and fail.",
  "root_cause_type": "generic",
  "root_cause_zh": "Python 3.12 移除了标准库 distutils 模块。旧的 setup.py 脚本或旧版 setuptools 直接导入 distutils 从而失败。",
  "versions": [
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "There is no distutils package on PyPI; pip reports 'No matching distribution found for distutils'.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The module doesn't exist to import; the shim itself raises ModuleNotFoundError.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "pip install 'setuptools>=68'\nexport SETUPTOOLS_USE_DISTUTILS=stdlib\npip install .",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "pip install --upgrade setuptools\npython -c \"import setuptools, setuptools._distutils; print('ok')\"\n# if still failing, use build isolation:\npip install --use-pep517 .",
      "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.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}