python system_error ai_generated true

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

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

pip is installing into a system site-packages directory owned by root without sufficient privileges.

generic

中文

pip 正在安装到由 root 拥有的系统 site-packages 目录,但没有足够的权限。

Workarounds

  1. 99% success
    python3 -m venv .venv
    source .venv/bin/activate
    pip install mypkg
  2. 90% success
    python3 -m pip install --user mypkg

Dead Ends

Common approaches that don't work:

  1. 40% fail

    Installing as root pollutes the system Python and can break OS tooling; also may still fail on immutable dirs.

  2. 70% fail

    Weakens system security and can break other tools relying on permissions.

  3. 85% fail

    --user is ignored when running as root, so it still targets system site-packages.