ERROR
pip
install_error
ai_generated
partial
ERROR: Cannot install package-a[extra1,extra2]==1.0 and package-b==2.0 because these package versions have conflicting dependencies. The conflict is caused by: package-a 1.0 depends on package-c>=3.0 and package-b 2.0 depends on package-c<3.0.
ID: pip/dependency-conflict-with-extras
80%Fix Rate
90%Confidence
1Evidence
2024-03-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| pip 23.2 | active | — | — | — |
| pip 24.1 | active | — | — | — |
| pip 24.2 | active | — | — | — |
Root Cause
Two requested packages have mutually exclusive version constraints on a shared dependency, and pip's resolver cannot find a version of the shared dependency that satisfies both constraints simultaneously.
generic中文
两个请求的包对共享依赖项有互斥的版本约束,pip 的解析器无法找到同时满足两个约束的共享依赖版本。
Official Documentation
https://pip.pypa.io/en/stable/topics/dependency-resolution/#conflicting-dependenciesWorkarounds
-
75% success Install an older version of package-a that depends on package-c<3.0: pip install 'package-a[extra1,extra2]<1.0' package-b==2.0
Install an older version of package-a that depends on package-c<3.0: pip install 'package-a[extra1,extra2]<1.0' package-b==2.0
-
60% success Use a virtual environment and install package-c at a version that satisfies both (e.g., package-c==2.99), then install packages without dependencies: pip install package-c==2.99 && pip install --no-deps package-a[extra1,extra2]==1.0 package-b==2.0
Use a virtual environment and install package-c at a version that satisfies both (e.g., package-c==2.99), then install packages without dependencies: pip install package-c==2.99 && pip install --no-deps package-a[extra1,extra2]==1.0 package-b==2.0
-
30% success Contact the package maintainers to relax version constraints or use a fork that resolves the conflict.
Contact the package maintainers to relax version constraints or use a fork that resolves the conflict.
中文步骤
安装旧版本的 package-a,该版本依赖于 package-c<3.0:pip install 'package-a[extra1,extra2]<1.0' package-b==2.0
使用虚拟环境,安装同时满足两个条件的 package-c 版本(例如 package-c==2.99),然后不安装依赖地安装包:pip install package-c==2.99 && pip install --no-deps package-a[extra1,extra2]==1.0 package-b==2.0
联系包维护者放宽版本约束,或使用解决冲突的分支。
Dead Ends
Common approaches that don't work:
-
Force install both packages with --no-deps to skip dependency resolution
85% fail
While this allows installation, the conflicting dependency package-c will be missing or have an incompatible version, causing runtime ImportError or AttributeError.
-
Upgrade pip to the latest version hoping the resolver improves
70% fail
The conflict is fundamental to the version constraints; no resolver can satisfy mutually exclusive requirements unless constraints are relaxed.