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?
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.
Adminstrator can use sudo (execute a command as root user) with your admin passed:
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):
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).