python system_error ai_generated true

警告:缓存条目反序列化失败,条目被忽略 错误:由于 OSError: [Errno 13] 权限被拒绝:'/root/.cache/pip/http-v2/...',无法安装包。

WARNING: Cache entry deserialization failed, entry ignored ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/root/.cache/pip/http-v2/...'

ID: python/pip-cache-write-permission-denied

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

版本兼容性

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

根因分析

pip 运行的用户与拥有 pip 缓存目录的用户不同,或缓存由 root 创建,现在非 root 用户尝试写入。

English

pip is running as a different user than the one that owns the pip cache directory, or the cache was created by root and now a non-root user tries to write to it.

generic

解决方案

  1. 90% 成功率
    Fix ownership or use a user-local cache:
      sudo chown -R $USER:$USER ~/.cache/pip
    Or:
      export PIP_CACHE_DIR=$HOME/.cache/pip-user
      mkdir -p $PIP_CACHE_DIR
      pip install <package>
  2. 85% 成功率
    Bypass the cache entirely for this install:
      pip install --no-cache-dir <package>

无效尝试

常见但无效的做法:

  1. 60% 失败

    Running as root fixes the immediate error but pollutes site-packages and can break the system Python.

  2. 50% 失败

    World-writable cache is a security risk and may still fail if the parent dir is not writable.