# 错误：无法安装 -r requirements.txt（第 4 行）和 package==1.2.3，因为这些包版本存在依赖冲突。

- **ID:** `python/pip-option-conflicts-with-requirement`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

requirements.txt 中固定的版本与嵌套 requirements 文件中的固定版本，或与已安装包的约束冲突。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (85% 成功率)
   ```
   Loosen the pin to a range: change 'package==1.2.3' to 'package>=1.2,<2'
   ```
2. **** (90% 成功率)
   ```
   Use pip-tools to compile a consistent lock: pip install pip-tools && pip-compile requirements.in
   ```
3. **** (80% 成功率)
   ```
   Inspect the conflict: pip install --dry-run -r requirements.txt -v
   ```

## 无效尝试

- **** — Skips all transitive deps, so the environment is incomplete and runtime imports fail. (85% 失败率)
- **** — Loses reproducibility and may pull a version incompatible with other pins. (60% 失败率)
- **** — -U upgrades top-level packages but does not resolve transitive conflicts and can break other pins. (75% 失败率)
