ERROR pip resolver_error ai_generated partial

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

Also available as: JSON · Markdown · 中文
78%Fix Rate
87%Confidence
1Evidence
2024-03-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
pip 23.3 active
pip 24.0 active
pip 24.1 active

Root Cause

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.

generic

中文

两个带有 extras 指定的包对共享依赖项具有不兼容的版本约束,pip 的解析器无法找到同时满足两者的 common-dep 版本。

Official Documentation

https://pip.pypa.io/en/stable/topics/dependency-resolution/

Workarounds

  1. 70% success Install the packages without extras that cause the conflict: pip install package-a package-b
    Install the packages without extras that cause the conflict: pip install package-a package-b
  2. 60% success Use a virtual environment with different Python versions or package versions: python3.10 -m venv venv && source venv/bin/activate && pip install package-a[extra1] && pip install package-b[extra2]
    Use a virtual environment with different Python versions or package versions: python3.10 -m venv venv && source venv/bin/activate && pip install package-a[extra1] && pip install package-b[extra2]
  3. 80% success Check if one of the extras is unnecessary; if so, omit it. For example, if extra2 is optional, install package-b without it: pip install package-a[extra1] package-b
    Check if one of the extras is unnecessary; if so, omit it. For example, if extra2 is optional, install package-b without it: pip install package-a[extra1] package-b

中文步骤

  1. 安装不带导致冲突的 extras 的包:pip install package-a package-b
  2. 使用不同 Python 版本或包版本的虚拟环境:python3.10 -m venv venv && source venv/bin/activate && pip install package-a[extra1] && pip install package-b[extra2]
  3. 检查其中一个 extras 是否不必要;如果是,省略它。例如,如果 extra2 是可选的,安装不带它的 package-b:pip install package-a[extra1] package-b

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Without dependencies, the packages may fail to import or function correctly.

  2. 50% fail

    If the constraints are exclusive (e.g., >=2.0 and <2.0), no single version exists, so pinning fails.