python
install_error
ai_generated
true
错误:无效的依赖项:'requests==2.31.0 --no-deps'
ERROR: Invalid requirement: 'requests==2.31.0 --no-deps'
ID: python/pip-invalid-requirement-no-such-option
80%修复率
88%置信度
0证据数
2024-03-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
pip 将依赖项字符串按 PEP 508 语法解析;像 --no-deps 这样的标志不能嵌入到依赖项说明符中,必须作为单独的 CLI 参数传递。
English
pip parses requirement strings as PEP 508 syntax; flags like --no-deps cannot be embedded inside a requirement specifier and must be passed as separate CLI arguments.
解决方案
-
99% 成功率
pip install --no-deps 'requests==2.31.0'
-
98% 成功率
echo 'requests==2.31.0' > req.txt pip install --no-deps -r req.txt
无效尝试
常见但无效的做法:
-
85% 失败
Quoting does not change parsing; pip still treats the quoted text as one requirement and rejects the option token.
-
90% 失败
requirements.txt lines are requirement specifiers, not command lines; pip errors out on the same Invalid requirement message.
-
95% 失败
Backslashes are not valid in PEP 508 requirement names and produce a different parse error.