# DeprecationWarning：pkg_resources 作为 API 已弃用。请参阅 https://setuptools.pypa.io/en/latest/pkg_resources.html

- **ID:** `python/setuptools-pkg-resources-deprecated`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

代码导入 pkg_resources（例如用于入口点或资源访问）；setuptools 67+ 将其标记为已弃用，推荐使用 importlib.metadata 和 importlib.resources。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   from importlib.metadata import entry_points
eps = entry_points(group='console_scripts')
for ep in eps:
    print(ep.name, ep.value)
   ```
2. **** (88% 成功率)
   ```
   from importlib.resources import files
data = (files('mypkg') / 'data.txt').read_text()
   ```

## 无效尝试

- **** — Hides warnings but pkg_resources will be removed, breaking the code later. (75% 失败率)
- **** — Blocks security fixes and conflicts with packages that require newer setuptools. (80% 失败率)
