python system_error ai_generated true

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

ERROR: Could not install packages due to an EnvironmentError: [Errno 39] Directory not empty: '.../src/package.egg-info'

ID: python/pip-egg-info-dir-error

其他格式: JSON · Markdown 中文 · English
80%修复率
84%置信度
0证据数
2024-09-14首次发现

版本兼容性

版本状态引入弃用备注
3.8 active
3.9 active
3.10 active

根因分析

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

English

A stale .egg-info directory exists from a previous build, and pip's cleanup fails because the directory is not empty.

generic

解决方案

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

无效尝试

常见但无效的做法:

  1. Deleting the .egg-info directory manually but not the contents 50% 失败

    If the directory is not fully removed, pip may still detect it and fail.

  2. Running pip with `--no-clean` 90% 失败

    This flag skips cleanup after installation, but the error occurs during the build step, not after.