Unable to install pip: Permission denied error
Asked Answered
E

1

8

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?

Eustoliaeutectic answered 5/12, 2010 at 16:41 Comment(4)
Are you running the command as a super user? (sudo python setup.py install)?Sherr
python setup.py config --prefix=/path/to/directory/you/have/write/permissions/ && python setup.py install may helpScarce
Sudo WORKED! :) Resubmit as an answer and so I can mark it. (Is that something people do on StackOverflow?) Thanks!Eustoliaeutectic
In my case I simply do python3 setup.py install --prefix=~/.local/ which install it in ~/.local/bin/ (ensure set ~/.local/bin in $PATH too), no need install in /usr/local/bin/ without good reason.Fabric
C
17

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!

Clarendon answered 5/12, 2010 at 17:12 Comment(6)
I'm on Mac OS X, on my admin account. Thoughts?Eustoliaeutectic
sudo /bin/bash don't do that. Just do sudo suAnglosaxon
@Falmarri: does that mean there is no /bin/bash on OS X? Or that the shell exists and that sudo doesn't work with it?Clarendon
@Peter: Oh, I don't have a mac so I have no idea. I'm just saying sudo su is the more standard way of doing it.Anglosaxon
@Falmarri: It's not standard if you're such an old fart you didn't learn about sudo until it had been out for about 10 years! :-) I'd never seen sudo su before your post, but it makes perfect sense. I was curious and tried su, sudo su, and sudo /bin/bash, each followed by env > /tmp/env.X. Each of them produces a different set of environment variables/values in env.su, env.sudo.su, and env.sudo.bash -- that looks like a good way to get really subtle, hard-to-find bugs/variances ... sigh.Clarendon
If you want to keep your user environment settings you can do sudo su -Anglosaxon

© 2022 - 2024 — McMap. All rights reserved.