python
system_error
ai_generated
true
错误:[Errno 13] 权限被拒绝:'/usr/local/lib/python3.11/site-packages/mypkg-1.0.dist-info/METADATA'
error: [Errno 13] Permission denied: '/usr/local/lib/python3.11/site-packages/mypkg-1.0.dist-info/METADATA'
ID: python/pip-egg-info-permission-denied
80%修复率
88%置信度
0证据数
2024-09-21首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
pip 正在安装到由 root 拥有的系统 site-packages 目录,但没有足够的权限。
English
pip is installing into a system site-packages directory owned by root without sufficient privileges.
解决方案
-
99% 成功率
python3 -m venv .venv source .venv/bin/activate pip install mypkg
-
90% 成功率
python3 -m pip install --user mypkg
无效尝试
常见但无效的做法:
-
40% 失败
Installing as root pollutes the system Python and can break OS tooling; also may still fail on immutable dirs.
-
70% 失败
Weakens system security and can break other tools relying on permissions.
-
85% 失败
--user is ignored when running as root, so it still targets system site-packages.