sudo: pip: command not found in CentOS

Not ideal but works. You can always unlink it after the install to restore security.

sudo ln -s /usr/local/bin/pip /bin/pip

Puts pip in the root path bin. You can then run pip as sudo.


pip can be installed with below command :

yum -y install python-pip

If your facing any problem with GPG key (no such file or directory), then trigger below command:

rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6

then try install pip


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

Try sudo bash -c 'echo $PATH' to see where sudo is looking for commands; you can then symlink pip into one of those directories.

Tags:

Python

Centos

Pip