$PATH
is evaluated by your shell, so your check doesn't work as you expect it to.
/etc/sudoers
is configured to replace your PATH
with a default one.
sudo
does not load a login shell environment before executing the command, so the default PATH
from /etc/sudoers
is used. su -
does open a login shell, which involves loading /etc/profile
. See man bash
, section INVOCATION.
Just remove the PATH
reset in /etc/sudoers
. It's likely a rule called secure_path
.
CentOS
In CentOS you can add PATH
to the Defaults env_keep
section:
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
_XKB_CHARSET XAUTHORITY PATH"
Generally, homebrew
will install a formula
into /usr/local/Cellar/formula
and then place a link at /usr/local/bin/formula
.
To make use of your installed formulae, make sure /usr/local/bin
is in your $PATH
. Show your $PATH
by typing
echo $PATH
If /usr/local/bin
is not in your $PATH
, put this line at the end of your ~/.profile
file.
export PATH="/usr/local/bin:$PATH"
Now, check what pythons
are found on your OSX by typing:
which -a python
There should be one python found at /usr/bin/
(the Apple python) and one at /usr/local/bin/
which is the Homebrew python.
which python
will show you, which python is found first in your $PATH
and will be executed when you invoke python
.
If you want to know, where the executable is, show it by typing
ls -l $(which python)
This could look like this:
lrwxr-xr-x 1 root wheel 68 7 Mai 13:22 python -> /usr/local/bin/python
This will work for pip
as well.
If you show the results of this steps, we can probably help you much easier.
-- UPDATE --
You have /usr/local/bin/python
linked to /usr/local/Cellar/python/2.7.9/bin/python
. -> brew install python
worked.
show, if pip
is installed by typing
brew list python | grep pip
You should see
/usr/local/Cellar/python/2.7.9/bin/pip
If not, check, if there are links, which are not done with brew install
. Told you something like this:
"Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local"
To force the link and overwrite all conflicting files:
brew link --overwrite python
To list all files that would be deleted:
brew link --overwrite --dry-run python
** NO standard Apple /usr/bin/python
**
link from /usr/local/Cellar/python/2.7.9/bin/python
to /usr/bin/python
ln -s /usr/local/Cellar/python/2.7.9/bin/python /usr/bin/python
This is necessary for all python scripts beginning with #!/usr/bin/python
. Especialy easy_install
will fail, if link is not there.
Now, you are able to run
easy_install pip
Hope, you're making progress
Best Answer
Try using Disk Utility to repair file permissions -- with any luck, that should reset the setuid bit on the /usr/bin/sudo that you copied. It's a flag that lets sudo act as root even when it's not run as root, which obviously it needs to be able to do, but you'll need sudo to set it using the command line so you have a chicken-and-egg problem.