python module_error ai_generated true

ModuleNotFoundError: No module named 'pkg_resources'

ID: python/setuptools-pkg-resources-not-found

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-12-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

Root Cause

pkg_resources is part of setuptools, but the installed setuptools version is too old or missing.

generic

中文

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

Workarounds

  1. 95% success Upgrade or reinstall setuptools
    pip install --upgrade setuptools
  2. 90% success Install setuptools in the environment
    python -m pip install setuptools

Dead Ends

Common approaches that don't work:

  1. Installing pkg_resources separately from PyPI 90% fail

    pkg_resources is not a standalone package; it comes with setuptools.

  2. Using importlib.resources instead 70% fail

    This is a different API and may not be compatible with existing code.