A T
A T

Reputation: 13846

Unable to run virtualenv on OSX?

sudo virtualenv foo

New python executable in foo/bin/python
Installing setuptools.............done.
Installing pip....
  Complete output from command /private/tmp/foo/bin/python -x /private/tmp/foo/bin/easy_install /Library/Python/2.7/...ort/pip-1.2.1.tar.gz:
  /private/tmp/foo/bin/python: can't open file '/private/tmp/foo/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 8, in <module>
    load_entry_point('virtualenv==1.8.2', 'console_scripts', 'virtualenv')()
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 942, in main
    never_download=options.never_download)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 1054, in create_environment
    install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 655, in install_pip
    filter_stdout=_filter_setup)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 1020, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /private/tmp/foo/bin/python -x /private/tmp/foo/bin/easy_install /Library/Python/2.7/...ort/pip-1.2.1.tar.gz failed with error code 2

virtualenv foo

New python executable in foo/bin/python
Installing setuptools.............................
  Complete output from command /private/tmp/foo/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])






" /Library/Python/2.7/...ols-0.6c11-py2.7.egg:
  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-1712.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.

----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 8, in <module>
    load_entry_point('virtualenv==1.8.2', 'console_scripts', 'virtualenv')()
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 942, in main
    never_download=options.never_download)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 1052, in create_environment
    search_dirs=search_dirs, never_download=never_download)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 599, in install_setuptools
    search_dirs=search_dirs, never_download=never_download)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 571, in _install_req
    cwd=cwd)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 1020, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /private/tmp/foo/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])






" /Library/Python/2.7/...ols-0.6c11-py2.7.egg failed with error code 1

I am running Python 2.7.3 and have no packages installed except what comes by default, pip and virtualenv on OSX Mountain Lion.

Upvotes: 2

Views: 3984

Answers (2)

A T
A T

Reputation: 13846

Whoops, forgot to write my answer to this question.

My Python directory had a whole bunch of permission and package related problems; ended up doing a complete uninstall then installed the latest one from Python.org.

Been working fine ever since.

Upvotes: 4

glyphobet
glyphobet

Reputation: 1562

Your Python installation is somehow messed up.

First, running sudo virtualenv foo doesn't make any sense. The whole point of virtualenv is so that you don't ever need root access to install packages. You will never need sudo to use virtualenv.

Second, /Library/Python/2.7/site-packages/virtualenv.py is not included by default with Mountain Lion. Something has installed it there, so you are mistaken when you say you "have no packages installed except what comes by default". Depending on how you got that installed, it may be installed wrong.

It appears that even though you are creating a virtualenv, it's trying to install packages into /Library/Python/2.7/site-packages/, which shouldn't be possible. Could it be that you used sudo easy_install to install virtualenv, or manually put some packages in /Library/Python/2.7/site-packages/?

I would suggest un-doing and un-installing whatever you installed, getting your system back to standard Mac OS X set-up, and then using virtualenv-burrito instead, it is a one-step command that will install virtualenv and pip for you with no thinking required: https://github.com/brainsik/virtualenv-burrito

Upvotes: 6

Related Questions