ERROR pip install_error ai_generated partial

错误:pip的依赖解析器当前未考虑所有已安装的包。此行为是以下依赖冲突的来源。<package>已安装但缺少<dependency>。

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. <package> is installed but <dependency> is missing.

ID: pip/pip-requires-virtualenv

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
1证据数
2023-05-15首次发现

版本兼容性

版本状态引入弃用备注
pip 21.3 active
pip 22.0 active
pip 23.0 active

根因分析

pip的解析器在解析依赖时未检查所有已安装的包,导致当某个包需要未安装或不兼容版本的依赖时产生冲突。

English

Pip's resolver does not check the full set of installed packages when resolving dependencies, leading to conflicts when a package requires a dependency that is not installed or is an incompatible version.

generic

官方文档

https://pip.pypa.io/en/stable/topics/dependency-resolution/

解决方案

  1. 创建新的虚拟环境并使用固定版本安装包:`python -m venv venv && source venv/bin/activate && pip install -r requirements.txt`
  2. 使用 `pip check` 识别并手动修复缺失或冲突的依赖,然后安装缺失包:`pip install <missing-dependency>==<compatible-version>`

无效尝试

常见但无效的做法:

  1. 60% 失败

    The resolver behavior is inherent to pip's design and not fixed by version upgrades alone.

  2. 50% 失败

    This can break environment consistency and may reintroduce the same conflicts if requirements are not pinned.