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

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

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

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>
   ```

## 无效尝试

- **** — Running as root fixes the immediate error but pollutes site-packages and can break the system Python. (60% 失败率)
- **** — World-writable cache is a security risk and may still fail if the parent dir is not writable. (50% 失败率)
