python
module_error
ai_generated
true
ModuleNotFoundError: No module named 'pkg_resources'
ID: python/pkg-resources-missing
80%Fix Rate
88%Confidence
0Evidence
2024-04-18First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
setuptools is not installed in the active environment, or the environment was created without setuptools (e.g., some venv setups or distro Python without pip). Code importing pkg_resources fails.
generic中文
当前环境中未安装 setuptools,或环境创建时未包含 setuptools(例如某些 venv 配置或未安装 pip 的发行版 Python)。导入 pkg_resources 的代码因此失败。
Workarounds
-
95% success
Install setuptools into the active environment: python -m pip install setuptools
-
85% success
Migrate to importlib.metadata / importlib.resources: from importlib.metadata import version print(version('requests'))
Dead Ends
Common approaches that don't work:
-
95% fail
There is no standalone pkg_resources package on PyPI; it ships inside setuptools.
-
70% fail
Silences the error but any code depending on resource access still fails later.