ERROR pip config_error ai_generated true

错误:无法安装 <package-a> 和 <package-b>,因为这些包的版本存在冲突的依赖关系。冲突由以下原因引起:<package-c> 1.0 依赖于 <package-d>!=2.0,而 <package-e> 2.0 依赖于 <package-d>==2.0。

ERROR: Cannot install <package-a> and <package-b> because these package versions have conflicting dependencies. The conflict is caused by: <package-c> 1.0 depends on <package-d>!=2.0 and <package-e> 2.0 depends on <package-d>==2.0.

ID: pip/dependency-conflict-with-extras-and-markers

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

版本兼容性

版本状态引入弃用备注
pip 22.0 active
pip 23.1.2 active
pip 24.0 active

根因分析

依赖树中的两个或多个包要求共享依赖的互斥版本,创建了 pip 解析器无法解决的不可满足的约束。

English

Two or more packages in the dependency tree require mutually exclusive versions of a shared dependency, creating an unsatisfiable constraint that pip's resolver cannot resolve.

generic

官方文档

https://pip.pypa.io/en/stable/topics/dependency-resolution/#dealing-with-dependency-conflicts

解决方案

  1. 使用虚拟环境并显式安装兼容版本。示例:`pip install <package-c>==1.0 <package-e>==1.5`,其中版本已知兼容。测试后在 requirements.txt 文件中固定所有依赖项。
  2. 使用 `pip install <package-a> <package-b> --upgrade --upgrade-strategy eager` 强制 pip 将所有依赖项升级到最新的兼容版本,这可能会解决冲突。

无效尝试

常见但无效的做法:

  1. 75% 失败

    This flag skips dependency resolution entirely, but the installed packages may be broken at runtime due to missing or conflicting dependencies.

  2. 80% 失败

    The `--no-deps` flag only prevents installation of dependencies for that specific package, but the conflict may still exist in the shared dependency tree; runtime errors are likely.