ERROR
pip
system_error
ai_generated
true
错误:由于操作系统错误 [Errno 30] 只读文件系统,无法安装软件包
ERROR: Could not install packages due to an OSError: [Errno 30] Read-only file system: '/root/.cache/pip/http'
ID: pip/cache-read-only-filesystem
90%修复率
85%置信度
1证据数
2023-11-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| pip 23.0 | active | — | — | — |
| pip 24.0 | active | — | — | — |
| pip 24.2 | active | — | — | — |
根因分析
pip 的缓存目录位于只读文件系统上(例如在容器、CI 环境或具有只读权限的挂载卷中),阻止 pip 写入或更新缓存文件。
English
pip's cache directory is located on a read-only filesystem (e.g., in a container, CI environment, or mounted volume with read-only permissions), preventing pip from writing or updating cached files.
官方文档
https://pip.pypa.io/en/stable/topics/caching/解决方案
-
完全禁用 pip 的缓存:pip install --no-cache-dir <package>
-
将 PIP_CACHE_DIR 环境变量设置为可写位置:export PIP_CACHE_DIR=/tmp/pip-cache && pip install <package>
无效尝试
常见但无效的做法:
-
Run pip with sudo or as root to override permissions
90% 失败
The filesystem is genuinely read-only (e.g., mounted with -o ro); root cannot write to a read-only filesystem either. This often happens in Docker containers where the volume is mounted read-only.
-
Delete the cache directory manually with rm -rf /root/.cache/pip
95% 失败
Deletion also requires write permission to the filesystem; the same read-only restriction applies.