ERROR
pip
resolver_error
ai_generated
partial
错误:无法安装 package-a[extra1] 和 package-b[extra2],因为这些包版本对 common-dep 有冲突的依赖关系(package-a[extra1] 需要 common-dep>=2.0,package-b[extra2] 需要 common-dep<2.0)。
ERROR: Cannot install package-a[extra1] and package-b[extra2] because these package versions have conflicting dependencies on common-dep (package-a[extra1] requires common-dep>=2.0, package-b[extra2] requires common-dep<2.0).
ID: pip/dependency-conflicts-with-extras
78%修复率
87%置信度
1证据数
2024-03-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| pip 23.3 | active | — | — | — |
| pip 24.0 | active | — | — | — |
| pip 24.1 | active | — | — | — |
根因分析
两个带有 extras 指定的包对共享依赖项具有不兼容的版本约束,pip 的解析器无法找到同时满足两者的 common-dep 版本。
English
Two packages with extras specified have incompatible version constraints on a shared dependency, and pip's resolver cannot find a version of common-dep that satisfies both simultaneously.
官方文档
https://pip.pypa.io/en/stable/topics/dependency-resolution/解决方案
-
安装不带导致冲突的 extras 的包:pip install package-a package-b
-
使用不同 Python 版本或包版本的虚拟环境:python3.10 -m venv venv && source venv/bin/activate && pip install package-a[extra1] && pip install package-b[extra2]
-
检查其中一个 extras 是否不必要;如果是,省略它。例如,如果 extra2 是可选的,安装不带它的 package-b:pip install package-a[extra1] package-b
无效尝试
常见但无效的做法:
-
90% 失败
Without dependencies, the packages may fail to import or function correctly.
-
50% 失败
If the constraints are exclusive (e.g., >=2.0 and <2.0), no single version exists, so pinning fails.