python system_error ai_generated true

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
84%Confidence
0Evidence
2024-09-14First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active
3.9 active
3.10 active

Root Cause

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

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

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

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

  2. Running pip with `--no-clean` 90% fail

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