# 错误：由于 OSError 无法安装包：[Errno 28] 设备上没有剩余空间

- **ID:** `python/pip-no-space-left-on-device-cache`
- **领域:** python
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pip 的 HTTP 缓存或临时构建目录填满了磁盘。常见于 overlay 文件系统较小的 CI 容器，或者 pip 缓存在多次构建中无界增长时。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   pip cache purge && pip cache dir
   ```
2. **** (90% 成功率)
   ```
   export TMPDIR=/mnt/bigdisk/tmp && mkdir -p $TMPDIR && pip install package
   ```
3. **** (85% 成功率)
   ```
   pip config set global.cache-dir /tmp/pipcache && pip install --no-cache-dir package
   ```

## 无效尝试

- **** — Disables caching but the build still needs temp space; if /tmp is full it still fails. (60% 失败率)
- **** — Changes install location but not disk usage; root filesystem is still full. (90% 失败率)
