error when “sudo pip” on an AWS ec2 instance


I am trying to run a small python code (which requries pytz and some other packages) on a aws ec2 instance. When I tried to install pytz, I got some errors:

I followed the accepted answer of this topic but got another error:

sudo:pip: command not found

Then I found out it might be because the path setting is wrong
(according to this page. But I could not manage to Just add ~/.local/bin to your path as suggested by the second answer.

Can someone show me how to add the bin to my path? I have no idea.

And some more info:


The default (secure_path) for sudo is specified in /etc/sudoers.

Since pip is not found in that path, you are getting the not found error. Preserve your PATH when running sudo by:

Leave a Reply