# 错误：由于环境错误无法安装包：[Errno 39] 目录非空：'.../src/package.egg-info'

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

## 根因

先前构建留下的过时 .egg-info 目录，pip 清理失败因为目录非空。

## 版本兼容性

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

## 解决方案

1. **Manually remove the .egg-info directory and its contents** (95% 成功率)
   ```
   `rm -rf src/package.egg-info` then re-run `pip install .`
   ```
2. **Use `pip install --no-build-isolation` to avoid build isolation issues** (80% 成功率)
   ```
   `pip install --no-build-isolation .`
   ```

## 无效尝试

- **Deleting the .egg-info directory manually but not the contents** — If the directory is not fully removed, pip may still detect it and fail. (50% 失败率)
- **Running pip with `--no-clean`** — This flag skips cleanup after installation, but the error occurs during the build step, not after. (90% 失败率)
