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'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

3 Answers 3

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
    
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

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

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.