python
config_error
ai_generated
true
错误:无效的需求:'foo bar==1.0'(来自 requirements.txt 第 3 行)。提示:看起来像路径。文件 'foo bar==1.0' 不存在。
ERROR: Invalid requirement: 'foo bar==1.0' (from line 3 of requirements.txt) Hint: It looks like a path. File 'foo bar==1.0' does not exist.
ID: python/pip-invalid-metadata-missing-name
80%修复率
83%置信度
0证据数
2024-05-27首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
requirements 行包含未加引号的空格或多余文本,pip 无法将其解析为需求,于是回退为将其解释为本地路径。
English
The requirements line contains an unquoted space or stray text, so pip cannot parse it as a requirement and falls back to interpreting it as a local path.
解决方案
-
94% 成功率
# requirements.txt: foo==1.0 python -c "from packaging.requirements import Requirement; [Requirement(l.strip()) for l in open('requirements.txt') if l.strip()]" pip install -r requirements.txt -
90% 成功率
foo==1.0; python_version >= '3.9'
无效尝试
常见但无效的做法:
-
90% 失败
Parsing behavior is stable; the malformed line still fails.
-
85% 失败
Adding a find-links path does not make the malformed requirement valid.