zimmer zimmer - 1 year ago 273
Python Question

sudo: pip: command not found in CentOS

I use CentOS and I installed pip to

. I made a link to
. Then I executed
sudo pip install xxx
, it reported an error like this:

sudo: pip: command not found

I see
is all right:


However, I can only execute pip this way:

sudo /usr/local/bin/pip install xxx

How can I configure PATH or something else? Thanks a lot.

Answer Source

For security reasons, sudo does not rely on the $PATH set in your environment. There is a secure_path option in /etc/sudoers that specifies the PATH that sudo will use for locating binaries. For example:

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin

Just add /usr/local/bin to this PATH, or get used to typing:

sudo `which pip` install xxx