# 错误：无效的需求：'requests==2.31.0'  提示：= 不是有效的运算符。您是否想用 == ？

- **ID:** `python/pip-invalid-requirement-parsing-error`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

requirements 文件或命令行参数中包含格式错误的版本说明符，最常见的是使用单个 '=' 而非 '=='，或版本约束内有多余的逗号/空格，导致打包解析器拒绝。

## 版本兼容性

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

## 解决方案

1. **** (98% 成功率)
   ```
   Replace single '=' with '==' and remove spaces around specifiers:
# bad
requests = 2.31.0
# good
requests==2.31.0
# or use a range
requests>=2.28,<3
   ```
2. **** (95% 成功率)
   ```
   Shell metacharacters like '>' and '<' must be quoted:
pip install 'requests>=2.28,<3'
   ```

## 无效尝试

- **** — The parser is behaving correctly; the requirement string is genuinely invalid regardless of pip version. (90% 失败率)
- **** — The error is in the requirement text, not the environment, so a fresh venv reproduces it identically. (85% 失败率)
- **** — --no-deps only skips dependency resolution, not parsing of the top-level requirement. (80% 失败率)
