python install_error ai_generated true

错误:无法安装 foo==1.0 和 bar==2.0,因为这些包版本的依赖存在冲突。冲突原因:foo 1.0 依赖 baz<2;bar 2.0 依赖 baz>=2

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

其他格式: JSON · Markdown 中文 · English
80%修复率
87%置信度
0证据数
2024-05-20首次发现

版本兼容性

版本状态引入弃用备注
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

根因分析

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

English

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

解决方案

  1. 85% 成功率
    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% 成功率
    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

无效尝试

常见但无效的做法:

  1. 85% 失败

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

  2. 80% 失败

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