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

- **ID:** `python/pip-cache-permission-denied`
- **领域:** python
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

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

## 无效尝试

- **** — Installs packages system-wide and may cause permission issues later; not recommended in virtualenvs. (70% 失败率)
- **** — If you lack permission to delete it, the error persists; also loses cache benefits. (60% 失败率)
