python
install_error
ai_generated
true
错误:无法安装 -r requirements.txt(第 4 行)和 package==1.2.3,因为这些包版本存在依赖冲突。
ERROR: Cannot install -r requirements.txt (line 4) and package==1.2.3 because these package versions have conflicting dependencies.
ID: python/pip-option-conflicts-with-requirement
80%修复率
85%置信度
0证据数
2024-09-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
requirements.txt 中固定的版本与嵌套 requirements 文件中的固定版本,或与已安装包的约束冲突。
English
A pinned version in requirements.txt conflicts with a version pinned in a nested requirements file or with an installed package's constraint.
解决方案
-
85% 成功率
Loosen the pin to a range: change 'package==1.2.3' to 'package>=1.2,<2'
-
90% 成功率
Use pip-tools to compile a consistent lock: pip install pip-tools && pip-compile requirements.in
-
80% 成功率
Inspect the conflict: pip install --dry-run -r requirements.txt -v
无效尝试
常见但无效的做法:
-
85% 失败
Skips all transitive deps, so the environment is incomplete and runtime imports fail.
-
60% 失败
Loses reproducibility and may pull a version incompatible with other pins.
-
75% 失败
-U upgrades top-level packages but does not resolve transitive conflicts and can break other pins.