# 错误：由于环境错误无法安装包：[Errno 2] 没有这样的文件或目录：'/path/to/package.egg-info/PKG-INFO'

- **ID:** `python/pip-egg-info-directory-error`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

包的 egg-info 目录缺失或损坏，通常由于构建中断或手动删除导致，使 pip 在提取元数据时失败。

## 版本兼容性

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

## 解决方案

1. **Rebuild the package from source to regenerate egg-info** (85% 成功率)
   ```
   pip install --no-build-isolation --no-cache-dir --force-reinstall /path/to/package
   ```
2. **Manually create the egg-info directory if missing** (75% 成功率)
   ```
   mkdir -p /path/to/package.egg-info && touch /path/to/package.egg-info/PKG-INFO
   ```

## 无效尝试

- **Reinstalling with --no-cache-dir** — The cache is not the issue; the egg-info is missing from the source, so cache clearing doesn't help. (70% 失败率)
- **Running pip install as root** — Permission changes don't recreate missing egg-info files; the problem persists regardless of user privileges. (80% 失败率)
