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
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.
解决方案
-
95% 成功率
pip install --cache-dir /tmp/pip-cache package
-
90% 成功率
sudo chown -R $USER:$USER ~/.cache/pip
无效尝试
常见但无效的做法:
-
70% 失败
Installs packages system-wide and may cause permission issues later; not recommended in virtualenvs.
-
60% 失败
If you lack permission to delete it, the error persists; also loses cache benefits.