python
runtime_error
ai_generated
true
弃用警告:pkg_resources 作为 API 已弃用。请参阅 https://setuptools.pypa.io/en/latest/pkg_resources.html
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
ID: python/setuptools-pkg-resources-deprecation-warning
80%修复率
86%置信度
0证据数
2024-05-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
setuptools 中的 pkg_resources 模块已被弃用,并将在未来版本中移除。代码或依赖项仍在导入它,从而触发警告。
English
The pkg_resources module from setuptools is deprecated and will be removed in future versions. Code or dependencies still import it, triggering the warning.
解决方案
-
85% 成功率
Replace pkg_resources usage with importlib.metadata and importlib.resources from the standard library.
-
80% 成功率
If the warning comes from a third-party package, update it to the latest version that no longer uses pkg_resources.
无效尝试
常见但无效的做法:
-
90% 失败
Hides the warning but does not fix the underlying deprecated usage; future removal will break the code.
-
70% 失败
Temporary workaround but loses security fixes and new features; not sustainable.