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
?
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.
根据这里: https : //unix.stackexchange.com/a/83194 ,你应该能够像这样运行这个命令:
sudo env 'PATH=$PATH:/usr/local/bin' pip ...
你试过只做 sudo su 看看它是否有效?
Wherever pip lives, it's not in your path when you sudo. So try this:
sudo /usr/local/bin/pip
If that doesn't work, then say which pip
to find out where pip lives, and proceed accordingly.
It seems like pip is not installed at system level. You can install pip
at system level by running sudo apt-get install python-pip
from terminal.After this you can upgrade pip
by running sudo pip install --upgrade pip
.
如果您使用sudo env "PATH=$PATH" pip install xxx
,您应该能够运行正确的pip
可执行文件。
Have you tried
sudo -H <your_commands>
?
This should preserve your user environment.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.