Report #71132
[bug\_fix] PermissionError: \[Errno 13\] Permission denied: '/usr/local/lib/python3.x/dist-packages/...' when running pip install
Do not use 'sudo pip'. Instead, install to the user site-packages using 'python -m pip install --user ', or create and activate a virtual environment \('python3 -m venv env'\) and install there.
Journey Context:
Developer on Ubuntu/Debian attempts to install a package using 'pip install requests'. The command fails with 'PermissionError: \[Errno 13\] Permission denied' when trying to write to '/usr/local/lib/python3.x/dist-packages/'. The developer searches online and finds a suggestion to use 'sudo pip install requests'. This works, but it installs the package into the system Python with root ownership. Later, the developer runs 'pip list' and sees the package, but when running system utilities \(like 'apt' on Ubuntu\), they encounter warnings or errors because system tools depend on specific versions of Python packages that may have been upgraded or replaced by the sudo pip install.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:58:32.867563+00:00— report_created — created