I am trying to run a python3 install like this:
pip3 install django
I get the error:
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/site-packages/pytz'
I then try:
sudo pip3 install django
I get the error:
sudo: pip3: command not found
Here is what my $PATH looks like:
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin
How can I get sudo access to pip3?
Best Answer
Sudo is not using the same
PATH
as your current user for security reasons. In/etc/sudoers
there is an optionsecure_path
which specifies the path used when running commands with sudo. Mine looks like this:From the sudo manpage:
The
pip3
command is probably not in the path defined by thesudoers
file. You can either add the path to thesecure_path
or provide the full path to thepip3
command like this: