pip
and sudo
are not on the same path on my machine, so when (basically all the time) I need to run both commands, like so:
sudo pip install xxx
I get:
sudo: pip: command not found
pip
downloads packages, but since access is being denied at the end of installation, it ends up failing.
by doing pip -V
, (which pip
returns nothing) I get to know where pip is:
pip 1.5.4 from /Library/Python/2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)
and by doing sudo bash -c 'echo $PATH'
,
I get:
/usr/bin:~/bin:/bin:/usr/local/bin:/usr/local/sbin:/Applications/Zed.app/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin
I have tried to symlink pip into sudo's directories, like so:
$ sudo ln -s /usr/local/bin/pip /usr/bin/pip
, to no avail.
How do I put sudo
on the same path
?
A “pip: command not found” error occurs when you fail to properly install the package installer for Python (pip) needed to run Python on your computer. To fix it, you will either need to re-install Python and check the box to add Python to your PATH or install pip on your command line.
Never ever ever ever use pip or pip3 with sudo . Use pip --user or Python virtual environments instead.
According to here: https://unix.stackexchange.com/a/83194, you should be able to run this command like this:
sudo env 'PATH=$PATH:/usr/local/bin' pip ...
After installing pip, I did
sudo ln -s /usr/local/bin/pip /usr/bin/pip
and now root can use pip without any PATH modifications. I had trouble making PATH modifications to the root account.
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