python
data_error
ai_generated
true
错误:由于 OSError 无法安装包:[Errno 2] 没有那个文件或目录:'.../METADATA'
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '.../METADATA'
ID: python/pip-metadata-file-not-found
80%修复率
82%置信度
0证据数
2024-07-22首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
根因分析
先前部分安装或损坏的包目录缺少必需的 METADATA 文件,导致 pip 在元数据验证期间失败。
English
A previously partially installed or corrupted package directory lacks the required METADATA file, causing pip to fail during metadata validation.
解决方案
-
95% 成功率 Remove the corrupted package directory manually
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.
-
85% 成功率 Use pip's `--no-cache-dir` and reinstall
`pip install --no-cache-dir --force-reinstall <package_name>`
无效尝试
常见但无效的做法:
-
Reinstalling the package with `--force-reinstall`
50% 失败
If the existing broken directory is not cleaned, pip may still encounter the same missing file.
-
Manually creating an empty METADATA file
90% 失败
The METADATA file must contain valid package metadata; an empty file will cause parsing errors.