# 错误：由于 OSError 无法安装包：[Errno 2] 没有那个文件或目录：'.../METADATA'

- **ID:** `python/pip-metadata-file-not-found`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

先前部分安装或损坏的包目录缺少必需的 METADATA 文件，导致 pip 在元数据验证期间失败。

## 版本兼容性

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

## 解决方案

1. **Remove the corrupted package directory manually** (95% 成功率)
   ```
   Find the site-packages directory (e.g., `python -m site --user-site`), then delete the package folder (e.g., `rm -rf <package_name>-*`). Then reinstall.
   ```
2. **Use pip's `--no-cache-dir` and reinstall** (85% 成功率)
   ```
   `pip install --no-cache-dir --force-reinstall <package_name>`
   ```

## 无效尝试

- **Reinstalling the package with `--force-reinstall`** — If the existing broken directory is not cleaned, pip may still encounter the same missing file. (50% 失败率)
- **Manually creating an empty METADATA file** — The METADATA file must contain valid package metadata; an empty file will cause parsing errors. (90% 失败率)
