{
  "id": "python/setuptools-pkg-resources-deprecated-removed",
  "signature": "UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30.",
  "signature_zh": "UserWarning：pkg_resources 作为 API 已弃用。参见 https://setuptools.pypa.io/en/latest/pkg_resources.html。pkg_resources 包最早将于 2025-11-30 移除。",
  "regex": "UserWarning:\\ pkg_resources\\ is\\ deprecated\\ as\\ an\\ API\\.\\ See\\ https://setuptools\\.pypa\\.io/en/latest/pkg_resources\\.html\\.\\ The\\ pkg_resources\\ package\\ is\\ slated\\ for\\ removal\\ as\\ early\\ as\\ 2025\\-11\\-30\\.",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Code (directly or via a dependency) imports pkg_resources, which setuptools has deprecated and scheduled for removal. Common in older packages using pkg_resources.get_distribution or resource_filename.",
  "root_cause_type": "generic",
  "root_cause_zh": "代码（直接或通过依赖）导入了 pkg_resources，setuptools 已弃用该 API 并计划移除。常见于使用 pkg_resources.get_distribution 或 resource_filename 的旧包。",
  "versions": [
    {
      "version": "3.8+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Hides the symptom only; the import still executes and will hard-fail once pkg_resources is removed. Also masks the real migration need.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Pins you to an unsupported setuptools, breaks modern build backends, and merely defers the removal. Downstream packages may require newer setuptools.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "from importlib.metadata import version, distribution\nprint(version('requests'))\n\nfrom importlib.resources import files\n# replaces pkg_resources.resource_filename\npath = files('mypkg').joinpath('data.txt')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "python -W error::DeprecationWarning -c 'import mypkg'  # traceback shows importer\npip install -U <offending-package>  # upgrade to a release using importlib",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}