python module_error ai_generated true

ModuleNotFoundError: 没有名为 'pkg_resources' 的模块

ModuleNotFoundError: No module named 'pkg_resources'

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

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

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

无效尝试

常见但无效的做法:

  1. Installing pkg_resources separately from PyPI 90% 失败

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

  2. Using importlib.resources instead 70% 失败

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