# ModuleNotFoundError: 没有名为 'pkg_resources' 的模块

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

## 根因

pkg_resources 是 setuptools 的一部分，但安装的 setuptools 版本过旧或缺失。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **Upgrade or reinstall setuptools** (95% 成功率)
   ```
   pip install --upgrade setuptools
   ```
2. **Install setuptools in the environment** (90% 成功率)
   ```
   python -m pip install setuptools
   ```

## 无效尝试

- **Installing pkg_resources separately from PyPI** — pkg_resources is not a standalone package; it comes with setuptools. (90% 失败率)
- **Using importlib.resources instead** — This is a different API and may not be compatible with existing code. (70% 失败率)
