python install_error ai_generated true

ERROR: Cannot install foo==1.0 and bar==2.0 because these package versions have conflicting dependencies. The conflict is caused by: foo 1.0 depends on baz<2; bar 2.0 depends on baz>=2

ID: python/pip-resolver-conflict-incompatible

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-05-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

Root Cause

The new pip resolver (pip >= 20.3) performs full backtracking and detects that no single set of versions satisfies all constraints. Two dependencies require mutually exclusive ranges of a shared package.

generic

中文

新版 pip 解析器(pip >= 20.3)执行完整回溯,发现没有任何一组版本能同时满足所有约束。两个依赖对同一个共享包要求互斥的版本范围。

Workarounds

  1. 85% success
    pip install 'foo<1.0' 'bar>=2'  # try ranges
    # or use pip-tools to resolve:
    pip install pip-tools
    pip-compile requirements.in
  2. 75% success
    python -m venv venv_foo && venv_foo/bin/pip install foo
    python -m venv venv_bar && venv_bar/bin/pip install bar
    # call via subprocess from a coordinating process

Dead Ends

Common approaches that don't work:

  1. 85% fail

    The legacy resolver just picks one arbitrarily and installs an inconsistent environment that breaks at runtime with ImportError or AttributeError.

  2. 80% fail

    Skips dependency installation entirely, leaving baz missing or at the wrong version so imports fail.