Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm on OS X Lion and wanting to setup python virtual environments. I want to use virtualenvwrapper.

Can someone confirm that the correct way to do this is to install packages via easy_install (and subsequently pip) is using sudo

Context: to install virtaulenv i wanted to use pip, so i did

$ easy_install pip
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-876.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /Library/Python/2.7/site-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  http://peak.telecommunity.com/EasyInstall.html

Please make the appropriate changes for your system and try again.

it seems the only way i can get easy_install to work is to do it using sudo. I've read elsewhere that this is a bad idea (although I'm not entirely sure why).

To clarify,

$ which python
/usr/bin/python

and it is 2.7.1.

share|improve this question

Making /Library/Python/2.7/site-packages/ world-executable with:

sudo chmod -R 755 /Library/Python/2.7/site-packages

worked for me.

share|improve this answer

Before Lion, /Library/Python was by default user-writeable (unless you started using sudo easy_install once, after which the newly created files were not user-writeable anymore). This has changed with Lion, although it is not clear why. So, you can either change ownership of /Library/Python or add sudo to all easy_install actions.

See homebrew wiki for more details.

share|improve this answer
1  
chmod +a 'user:YOUR_NAME_HERE allow add_subdirectory,add_file,delete_child,directory_inherit' /Library/Python/2.7/site-packages – tzs Aug 9 '12 at 19:41

Downloading setuptools again and installing it with this command will fix your problem.

sudo sh setuptools-0.6c11-py2.7.egg --prefix=~ --install-dir=/Library/Python/2.7/site-packages/
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .