python data_error ai_generated true

ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '.../METADATA'

ID: python/pip-metadata-file-not-found

Also available as: JSON · Markdown · 中文
80%Fix Rate
82%Confidence
0Evidence
2024-07-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active
3.9 active
3.10 active

Root Cause

A previously partially installed or corrupted package directory lacks the required METADATA file, causing pip to fail during metadata validation.

generic

中文

先前部分安装或损坏的包目录缺少必需的 METADATA 文件,导致 pip 在元数据验证期间失败。

Workarounds

  1. 95% success Remove the corrupted package directory manually
    Find the site-packages directory (e.g., `python -m site --user-site`), then delete the package folder (e.g., `rm -rf <package_name>-*`). Then reinstall.
  2. 85% success Use pip's `--no-cache-dir` and reinstall
    `pip install --no-cache-dir --force-reinstall <package_name>`

Dead Ends

Common approaches that don't work:

  1. Reinstalling the package with `--force-reinstall` 50% fail

    If the existing broken directory is not cleaned, pip may still encounter the same missing file.

  2. Manually creating an empty METADATA file 90% fail

    The METADATA file must contain valid package metadata; an empty file will cause parsing errors.