12

I have installed python 2.7.8 via make and make install and then pip via get-pip. I have to note that I work behind a proxy which I have set up via

  • http_proxy
  • ftp_proxy
  • https_proxy

in

  • my user's ~/.zshrc
  • root's /root/.basrc

now I am able to run pip

  • on my user account
  • on root account

but I am not able to run it via my user's shell using sudo

sudo pip
sudo: pip: command not found

What is wrong here?

Patryk
  • 13,556
  • 22
  • 53
  • 61

1 Answers1

19

That'll be because the PATH is different when running with sudo. Try comparing:

which pip
env

vs.

sudo which pip
sudo env

One secure workaround is to create a symbolic link to pip in /usr/local/bin or even /usr/bin. If you install pip using a package manager it will do this automatically on several (most?) distros.

l0b0
  • 50,672
  • 41
  • 197
  • 360
  • 6
    thanks, `alias sudo='sudo env PATH=$PATH'` solved the issue. – Patryk Nov 21 '14 at 15:36
  • There are security issues with that - you don't want to blindly set this in all your environments! – l0b0 Nov 21 '14 at 15:39
  • 7
    I'm not sure if it was super clear in this answer, but the solution is indeed a `ln -s /usr/local/bin/ /usr/bin/` – JulienD Aug 19 '15 at 08:35