python
module_error
ai_generated
true
SetuptoolsDeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
ID: python/setuptools-pkg-resources-deprecated
80%Fix Rate
88%Confidence
0Evidence
2024-01-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
Root Cause
Code (often a third-party library) imports pkg_resources, which setuptools plans to remove; the warning surfaces at import time.
generic中文
代码(通常是第三方库)导入了 pkg_resources,setuptools 计划移除它;该警告在导入时出现。
Workarounds
-
90% success
Replace pkg_resources usage with importlib.metadata: # old: pkg_resources.get_distribution('foo').version from importlib.metadata import version version('foo') -
80% success
If the import is inside a third-party lib, upgrade it: pip install --upgrade <lib> Check with: pip list --outdated
-
60% success
Suppress narrowly in pyproject.toml [tool.pytest.ini_options] filterwarnings if you cannot upgrade yet.
Dead Ends
Common approaches that don't work:
-
80% fail
Newer setuptools still ships pkg_resources but emits the warning; upgrading does not silence it.
-
60% fail
Hides the warning but the underlying API will be removed; the library will break eventually.