# 警告：忽略无效的分发 -ip（位于 site-packages）。错误：无效的需求：'foo=>1.0'（来自 requirements.txt 第 1 行）。提示：= 不是有效运算符，是否想用 ==？

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

## 根因

requirements 文件使用了无效的版本运算符（=> 而非 >=）或 packaging 拒绝的格式错误说明符。此外，部分卸载的发行版在 site-packages 中残留了 '~ip' 或 '-ip' 存根目录。

## 版本兼容性

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

## 解决方案

1. **** (93% 成功率)
   ```
   sed -i 's/=>/>=/g' requirements.txt
# remove leftover '~' dirs
find $(python -c 'import site; print(site.getsitepackages()[0])') -maxdepth 1 -name '~*' -exec rm -rf {} +
pip install -r requirements.txt
   ```
2. **** (90% 成功率)
   ```
   python -c "from packaging.requirements import Requirement; [Requirement(l) for l in open('requirements.txt') if l.strip() and not l.startswith('#')]"
   ```

## 无效尝试

- **** — The syntax error is in the requirements file, not pip; upgrading changes nothing and the invalid operator still fails. (90% 失败率)
- **** — Overly destructive; breaks the base interpreter and does not fix the malformed requirements line. (70% 失败率)
