# 错误：无效的需求：'package[extra1,extra2]'（requirements.txt 第 1 行）。提示：= 不是有效运算符。您是不是想用 ==？

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

## 根因

requirements.txt 中的一行在 extras 规范后使用了单等号 (=) 进行版本固定，但 pip 要求使用双等号 (==) 表示精确版本约束。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pip 22.0 | active | — | — |
| pip 23.1 | active | — | — |
| pip 24.0 | active | — | — |

## 解决方案

1. ```
   编辑 requirements.txt 使用双等号：`package[extra1,extra2]==1.0`
   ```
2. ```
   如果不需要固定版本，移除版本说明符：`package[extra1,extra2]`
   ```
3. ```
   使用 `pip install -r requirements.txt --no-deps` 临时绕过无效行，然后修复文件。
   ```

## 无效尝试

- **Remove the extras brackets entirely and reinstall without extras.** — The user may need the extras for functionality; removing them is a workaround but not a fix. (60% 失败率)
- **Change the operator to >= instead of ==.** — The error is about the single equals sign, not the operator type; >= also requires double equals. (90% 失败率)
- **Ignore the error and use `pip install package[extra1,extra2]==1.0` directly on CLI.** — The CLI command works, but the requirements.txt remains broken for future installs or CI. (70% 失败率)
