Unable to install pip: Permission denied error

Eitan picture Eitan · Dec 5, 2010 · Viewed 53.4k times · Source

I am trying to install pip but currently unable to. I navigate to the pip folder and

python setup.py install

Everything seems to go fine until the very end:

Extracting pip-0.8.2-py2.6.egg to /Library/Python/2.6/site-packages
Adding pip 0.8.2 to easy-install.pth file
Installing pip script to /usr/local/bin
error: /usr/local/bin/pip: Permission denied

I've also tried easy_install . and attempted to refer to the related thread with no luck: Python install uninstall easy_install

Any ideas?

Answer

Peter Rowell picture Peter Rowell · Dec 5, 2010

Looks like you're on an Linux/Unix box and you're not root ... which means you don't have permission to put things in /usr/local/bin (or a lot of other places).

Update for comments:

Since OS X is (under the hood) FreeBSD Unix, there is still the basic concept of 'root'. Your admin account is capable of doing root-type things, but it doesn't automatically escalate privileges (which is a Good Thing). The command you are looking for is sudo, which provides temporary root privileges. To do it for a single command (the most normal case), simply prefix the command with sudo, e.g. sudo python setup.py install. You will probably be prompted to supply your password again (not root's password, but your own) and then the command will be executed. sudo will only prompt you the first time (or every N minutes) for a password.

I noted here that in 10.5 and later, sudo will only work if your admin account has a password. If it doesn't, then you will have to set one before this will work.

If you have a whole bunch of stuff you need to do as root, try sudo /bin/bash (or you shell of choice), which will give you a new shell (as a child process of the other shell) which has full root privileges. Note Well: if you are not use to living at a root-prompt, this is not a great idea. One slip of the keyboard and you can nail your system to the outhouse wall. So be careful out there!