python system_error ai_generated true

错误:由于 OSError 无法安装包:[Errno 28] 设备上没有剩余空间

ERROR: Could not install packages due to an OSError: [Errno 28] No space left on device

ID: python/pip-no-space-left-on-device

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

版本兼容性

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

根因分析

承载 pip 缓存或目标 site-packages 的文件系统空间已耗尽,通常是由于 ~/.cache/pip 中积累了大量 wheel 下载。

English

The filesystem hosting the pip cache or the target site-packages has run out of space, often after many wheel downloads accumulate in ~/.cache/pip.

generic

解决方案

  1. 95% 成功率
    pip cache purge
    # or manually
    rm -rf ~/.cache/pip
    df -h ~
    pip install somepkg
  2. 90% 成功率
    export PIP_CACHE_DIR=/mnt/bigdisk/pip-cache
    pip install somepkg
    # or persist it
    pip config set global.cache-dir /mnt/bigdisk/pip-cache

无效尝试

常见但无效的做法:

  1. 70% 失败

    Avoids new cache writes but the target site-packages still needs space and may be on the same full volume.

  2. 90% 失败

    Upgrading pip itself needs space and does not free any.