Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to install files to /Library/Python/2.7/site-packages on OS-X 10.8. I am logged in as Administrator, but I still get an error 'Permission denied'. Same error when I try to create a directory there from Terminal. I apparently don't have permission to write into the root area. How do I fix this?

share|improve this question

1 Answer 1

Being logged in to MacOSX as "an administrator" grants you permission to execute certain privileged commands, but it does not make you root (user ID 0 - super user). The Python directory, and most everything under /Library, is owned and writable only by root: E.g.

mymac:Python kentalt$ ls -l
total 0
drwxr-xr-x  3 root  wheel  102 Jun 20  2012 2.3
drwxr-xr-x  3 root  wheel  102 Jun 20  2012 2.5
drwxr-xr-x  3 root  wheel  102 Jun 20  2012 2.6
drwxr-xr-x  3 root  wheel  102 Jun 20  2012 2.7
mymac:Python kentalt$ touch foo
touch: foo: Permission denied

Adminstrator can use sudo (execute a command as root user) with your admin passed:

mymac:Python kentalt$ sudo touch foo
Password:
mymac: Python kentalt$ ls -l
total 0
drwxr-xr-x  3 root  wheel  102 Jun 20  2012 2.3
drwxr-xr-x  3 root  wheel  102 Jun 20  2012 2.5
drwxr-xr-x  3 root  wheel  102 Jun 20  2012 2.6
drwxr-xr-x  3 root  wheel  102 Jun 20  2012 2.7
-rw-r--r--  1 root  wheel    0 Jan 10 08:57 foo

Note that you have to use sudo with each such command (if you run several such commands in a short period of time it will not ask for your password each time):

mymac:Python kentalt$ rm foo
override rw-r--r--  root/wheel for foo? y
rm: foo: Permission denied
mymac:Python kentalt$ sudo rm foo
mymac:Python kentalt$ ls
2.3 2.5 2.6 2.7

You could also change directory permissions to allow group or everyone to write to it, rather than doing all maintenance as root -- beware that permission changes can break some programs or may get reverted on system updates, though Python is probably fine. Or add a symlink for site-packages to somewhere else in user-writable space, so you keep your updates clearly separate from system supported files.

You can use "sudo bash" to start a shell session as root. This is a really, really dangerous thing to do, because root can do pretty much anything, and may not even require a sanity check before removing your entire system, e.g., "rm -rf . /*" (a typo every old unix admin has done at least once).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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