ERROR: Cannot install package-a and package-b because these package versions have conflicting dependencies. The conflict is caused by: The user requested package-a; package-b depends on package-a<2.0
ID: python/pip-dependency-resolver-backtracking-too-deep
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
Root Cause
pip's new resolver performs exhaustive backtracking when transitive dependency constraints conflict. The resolver explores every possible version combination, which can take minutes or hang indefinitely on large dependency trees with circular or deeply nested constraints.
generic中文
pip 的新解析器在传递依赖约束冲突时会执行穷举回溯。解析器会探索所有可能的版本组合,在大型依赖树或存在循环/深层嵌套约束时,可能耗时数分钟甚至无限挂起。
Workarounds
-
70% success
Use pip install --use-deprecated=legacy-resolver to fall back to the old non-backtracking resolver, which installs packages sequentially and may succeed with warnings.
-
85% success
Manually identify a compatible version set using pip install --dry-run -v and then pin exact versions in requirements.txt, e.g., package-a==1.2.3 and package-b==2.0.1.
-
90% success
Use pip-tools: pip-compile requirements.in to generate a fully pinned requirements.txt with compatible versions, then pip-sync.
Dead Ends
Common approaches that don't work:
-
75% fail
Bypasses all dependency checks, leading to runtime ImportError or AttributeError when packages are actually missing or incompatible.
-
65% fail
Latest versions often have their own new conflicts; resolver still backtracks, just with different constraints.
-
80% fail
The resolver algorithm is already current; upgrading doesn't change the fundamental conflict in dependency metadata.