# 错误：由于环境错误，无法安装包：找不到文件或目录：'.../egg-info/PKG-INFO'

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

## 根因

包的setup.py或setup.cfg引用了未生成的egg-info元数据，通常是由于缺少setup()调用或构建后端配置错误。

## 版本兼容性

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

## 解决方案

1. **** (85% 成功率)
   ```
   Ensure setup.py has a proper setup() call: `python setup.py egg_info` to pre-generate metadata, then pip install .
   ```
2. **** (90% 成功率)
   ```
   Switch to pyproject.toml with setuptools.build_meta: `[build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta"` and run pip install .
   ```
3. **** (75% 成功率)
   ```
   Clean rebuild: `rm -rf *.egg-info build dist && pip install --no-cache-dir .`
   ```

## 无效尝试

- **** — pip will overwrite or ignore manually created files, and the underlying metadata generation process is still broken. (95% 失败率)
- **** — This bypasses isolated build environments but doesn't fix the fundamental setup.py issue; the error persists if setup.py is malformed. (70% 失败率)
- **** — If the build backend doesn't regenerate it properly due to configuration errors, deletion alone won't solve the problem. (60% 失败率)
