# 错误：pip 的依赖解析器检测到冲突的要求。requirements.txt 文件包含 '<package>==1.0'，但 pip freeze 显示已安装 '<package>==2.0'。

- **ID:** `pip/conflict-with-requirements-txt-and-pip-freeze`
- **领域:** pip
- **类别:** config_error
- **错误码:** `ERROR`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

用户在 requirements.txt 中固定了一个与当前已安装版本不同的版本，pip 的解析器无法协调此冲突，因为已安装的版本违反了约束。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pip 22.3 | active | — | — |
| pip 23.0 | active | — | — |
| pip 23.2.1 | active | — | — |

## 解决方案

1. ```
   更新 requirements.txt 以匹配已安装的版本：运行 `pip freeze | grep <package>` 并将 requirements.txt 中的版本替换为输出。示例：`pip freeze | grep requests` 然后在 requirements.txt 中设置 `requests==2.31.0`。
   ```
2. ```
   使用 `--ignore-installed` 与 pip install 绕过检查：`pip install -r requirements.txt --ignore-installed <package>`
   ```

## 无效尝试

- **** — The upgrade may break other dependencies that rely on the newer version; pip's resolver will still complain if the upgrade is not possible due to other constraints. (70% 失败率)
- **** — This removes the constraint entirely, but pip may still detect the version mismatch if the package is a dependency of another package in the file. (60% 失败率)
