{
  "id": "python/setuptools-pkg-resources-deprecation-error",
  "signature": "DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html\nUserWarning: pkg_resources is deprecated as an API.",
  "signature_zh": "DeprecationWarning: pkg_resources 作为 API 已被弃用。参见 https://setuptools.pypa.io/en/latest/pkg_resources.html\nUserWarning: pkg_resources 作为 API 已被弃用。",
  "regex": "DeprecationWarning:\\ pkg_resources\\ is\\ deprecated\\ as\\ an\\ API\\.\\ See\\ https://setuptools\\.pypa\\.io/en/latest/pkg_resources\\.html\\\nUserWarning:\\ pkg_resources\\ is\\ deprecated\\ as\\ an\\ API\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Code or a dependency imports `pkg_resources`, which setuptools deprecated in favor of `importlib.metadata` and `importlib.resources`; under `-W error` it becomes a hard failure.",
  "root_cause_type": "generic",
  "root_cause_zh": "代码或依赖导入了 `pkg_resources`，setuptools 已弃用它，推荐改用 `importlib.metadata` 和 `importlib.resources`；在 `-W error` 下会变成硬错误。",
  "versions": [
    {
      "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": "Only postpones the removal; newer deps require modern setuptools.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides real issues and the API may be removed in a future release.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Migrate imports: replace `import pkg_resources; pkg_resources.get_distribution('x').version` with `from importlib.metadata import version; version('x')`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.7,
      "how": "If the warning comes from a dependency, pin a fixed version or open an issue; locally silence only that line with `warnings.filterwarnings('ignore', category=UserWarning, module='pkg_resources')`.",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-09-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}