python install_error ai_generated true

package-a 1.0.0 需要 package-b<2,但你已安装 package-b 2.3.0,不兼容。

package-a 1.0.0 requires package-b<2, but you have package-b 2.3.0 which is incompatible.

ID: python/pip-check-broken-requirements

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

版本兼容性

版本状态引入弃用备注
3.x active — — —

根因分析

已安装的包(通过 conda、apt 或之前的 --no-deps 安装)违反了声明的依赖约束。

English

An existing package installed outside pip's resolver (e.g., via conda, apt, or a previous --no-deps install) violates a declared dependency constraint.

generic

解决方案

  1. 92% 成功率
    Create a fresh venv and reinstall: python -m venv .venv && . .venv/bin/activate && pip install -r requirements.txt
  2. 85% 成功率
    Pin the correct version: pip install 'package-b<2'
  3. 80% 成功率
    Audit with pip check and pipdeptree: pip install pipdeptree && pipdeptree --warn silence

无效尝试

常见但无效的做法:

  1. 70% 失败

    Runtime imports may resolve to the wrong version and fail with AttributeError or ImportError.

  2. 60% 失败

    Force-reinstall may pull in conflicting transitive deps and break other packages in the same env.

  3. 95% 失败

    Removes the package you need instead of resolving the conflict.