I use CentOS and I installed pip to /usr/local/python-dir/bin/pip. I made a link to /usr/local/bin/pip. Then I executed sudo pip install xxx, it reported an error like this:
sudo: pip: command not found I see $PATH is all right:
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin 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.
Python PIP is not available in the official package repository of CentOS 7. But it is available in the EPEL package repository. Before you can install Python PIP on CentOS 7, you must add EPEL repository to your CentOS 7. Press 'y' and then press <Enter> to continue.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With