Report #104558
[bug\_fix] PermissionError: \[Errno 13\] Permission denied: '/usr/local/lib/python3.10/site-packages/'
Use a virtual environment \(\`python -m venv myenv\` and then \`myenv/bin/pip install ...\`\), or install with the \`--user\` flag \(\`pip install --user \`\), or run pip with sudo \(not recommended\).
Journey Context:
A developer on a shared university Linux machine tried to install \`numpy\` using \`pip install numpy\` without any virtual environment. The command failed with a PermissionError because the system site-packages directory is owned by root and the user had no write access. The developer tried \`sudo pip install numpy\`, which succeeded but later caused issues because the system Python's site-packages were modified for all users. The proper fix was to create a virtual environment: \`python -m venv myenv\`, activate it, and then install numpy. This isolated the installation to the user's home directory. The root cause is that the system Python's site-packages are protected; pip by default tries to write there. Using \`--user\` is another option but can still cause conflicts between projects. Virtual environments are the recommended best practice.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-06T20:05:19.082783+00:00— report_created — created