11

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?

17

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.

  • 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
  • 6
    I'm not sure if it was super clear in this answer, but the solution is indeed a ln -s /usr/local/bin/<stuff> /usr/bin/<stuff> – JulienD Aug 19 '15 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.