python
system_error
ai_generated
true
错误:由于 OSError 无法安装包:[Errno 13] 权限被拒绝:'/usr/local/lib/python3.11/site-packages/foo'
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/usr/local/lib/python3.11/site-packages/foo'
ID: python/pip-permission-denied-install
80%修复率
90%置信度
0证据数
2024-03-30首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
pip 试图在没有足够权限的情况下安装到系统目录。
English
pip is trying to install into a system directory without sufficient permissions.
解决方案
-
95% 成功率
Create and activate a virtual environment: `python -m venv venv && source venv/bin/activate && pip install foo`.
-
80% 成功率
If you must install globally, use `pip install --user foo`.
无效尝试
常见但无效的做法:
-
30% 失败
May work but can cause conflicts; better to use a virtual environment.
-
60% 失败
Can break system packages and is discouraged.