python system_error ai_generated true

错误:由于 OSError 无法安装包:[Errno 13] 权限被拒绝:'/root/.cache/pip'

ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/root/.cache/pip'

ID: python/pip-cache-permission-denied

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

版本兼容性

版本状态引入弃用备注
3.x active

根因分析

pip 以无权写入缓存目录的用户身份运行,通常是因为缓存由 root 或其他用户创建。

English

pip is running as a user without write access to the cache directory, often because the cache was created by root or another user.

generic

解决方案

  1. 95% 成功率
    pip install --cache-dir /tmp/pip-cache package
  2. 90% 成功率
    sudo chown -R $USER:$USER ~/.cache/pip

无效尝试

常见但无效的做法:

  1. 70% 失败

    Installs packages system-wide and may cause permission issues later; not recommended in virtualenvs.

  2. 60% 失败

    If you lack permission to delete it, the error persists; also loses cache benefits.