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-site-packages

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2024-11-09First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

Installing into a system-wide site-packages without write permission.

generic

中文

在没有写权限的情况下向系统级 site-packages 安装。

Workarounds

  1. 95% success
    python -m venv .venv && source .venv/bin/activate && pip install foo
  2. 90% success
    pip install --user foo

Dead Ends

Common approaches that don't work:

  1. 50% fail

    Mixes root-owned files into user environment, causing future permission errors and security risks.

  2. 80% fail

    Weakens system security and does not address root cause.