I get an Error 13 permission denied when installing packages into a virtual environment. I have not used sudo for pip, and recreating the environment did not fix it. What should I check?
Why does pip get permission denied inside my virtual environment?
Answers
Start by checking ownership and permissions on the exact directory named in the error, plus its parent directories. If any part of the environment is owned by another user or is not writable by you, pip cannot install there. The fact that sudo works points toward a permissions issue, but it does not by itself explain how it got that way.
Once you know what is wrong, fix ownership only for the project or virtual environment you control. Avoid running pip with sudo, since that can leave more files owned by the administrator account.
Reply to this answer
Before deleting anything, check that your shell is using the environment you mean to use. Compare the paths from which python and pip with the environment's Python, and try installing with python -m pip so pip is tied to that interpreter. Also check that the environment directory is in a location your account can write to.
If the paths are right and the permissions look normal, the exact error path and the output showing its owner and permissions are useful clues for narrowing it down.
Reply to this answer
If you are sure the virtual environment contains nothing you need, remove it and recreate it as your regular user in a writable project directory. But since recreating it has not helped, check the parent directory and ownership first. Rebuilding the environment in a location with the same restriction can reproduce the same error.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions