python
system_error
ai_generated
true
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/usr/local/lib/python3.10/site-packages/...'
ID: python/pip-permission-denied-system-site-packages
80%Fix Rate
89%Confidence
0Evidence
2024-01-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.7 | active | — | — | — |
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
Root Cause
pip is attempting to install into the system-wide site-packages directory without sufficient write permissions. This occurs when running pip without sudo on a system Python or when the directory is owned by root.
generic中文
pip 试图安装到系统级的 site-packages 目录,但没有足够的写入权限。这通常发生在未使用 sudo 运行 pip 或目录属于 root 用户时。
Workarounds
-
95% success
Install to user site-packages: pip install --user <package>.
-
98% success
Create and use a virtual environment: python -m venv myenv && source myenv/bin/activate && pip install <package>.
Dead Ends
Common approaches that don't work:
-
70% fail
Using sudo can install packages as root, causing permission issues later and potentially breaking the system Python environment.
-
85% fail
Creates security risks and may still fail if the directory is immutable or on a read-only filesystem.