# 错误：无效的需求：'foo bar==1.0'（来自 requirements.txt 第 3 行）。提示：看起来像路径。文件 'foo bar==1.0' 不存在。

- **ID:** `python/pip-invalid-metadata-missing-name`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

requirements 行包含未加引号的空格或多余文本，pip 无法将其解析为需求，于是回退为将其解释为本地路径。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (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
   ```
2. **** (90% 成功率)
   ```
   foo==1.0; python_version >= '3.9'
   ```

## 无效尝试

- **** — Parsing behavior is stable; the malformed line still fails. (90% 失败率)
- **** — Adding a find-links path does not make the malformed requirement valid. (85% 失败率)
