python
system_error
ai_generated
true
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%Fix Rate
90%Confidence
0Evidence
2024-03-30First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
Root Cause
pip is trying to install into a system directory without sufficient permissions.
generic中文
pip 试图在没有足够权限的情况下安装到系统目录。
Workarounds
-
95% success
Create and activate a virtual environment: `python -m venv venv && source venv/bin/activate && pip install foo`.
-
80% success
If you must install globally, use `pip install --user foo`.
Dead Ends
Common approaches that don't work:
-
30% fail
May work but can cause conflicts; better to use a virtual environment.
-
60% fail
Can break system packages and is discouraged.