python
module_error
ai_generated
true
ModuleNotFoundError: 没有名为 'pkg_resources' 的模块
ModuleNotFoundError: No module named 'pkg_resources'
ID: python/setuptools-pkg-resources-not-found
80%修复率
85%置信度
0证据数
2024-12-01首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
pkg_resources 是 setuptools 的一部分,但安装的 setuptools 版本过旧或缺失。
English
pkg_resources is part of setuptools, but the installed setuptools version is too old or missing.
解决方案
-
95% 成功率 Upgrade or reinstall setuptools
pip install --upgrade setuptools
-
90% 成功率 Install setuptools in the environment
python -m pip install setuptools
无效尝试
常见但无效的做法:
-
Installing pkg_resources separately from PyPI
90% 失败
pkg_resources is not a standalone package; it comes with setuptools.
-
Using importlib.resources instead
70% 失败
This is a different API and may not be compatible with existing code.