7

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.

3 Answers 3

4

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

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

worked for me.

1

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.

1
  • 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, 2012 at 19:41
1

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/

You must log in to answer this question.

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