简体   繁体   中英

Using virtualenv on Mac OS X Yosemite

I have been struggling with setting up virtualenv and pip on Mac OS X Yosemite. I keep running into the same problem:

$ virtualenv foobar
New python executable in foobar/bin/python
Installing setuptools, pip...
  Complete output from command /Users/name/foobar/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
  Ignoring indexes: https://pypi.python.org/simple
Collecting setuptools
Collecting pip
Installing collected packages: pip, setuptools

  Exception:
  Traceback (most recent call last):
    File "/Library/Python/2.7/site-packages/virtualenv-12.0.7-py2.7.egg/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/basecommand.py", line 232, in main
      status = self.run(options, args)
...
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 82, in copyfile
          with open(dst, 'wb') as fdst:
      IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip/__init__.py'

----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==12.0.7', 'console_scripts', 'virtualenv')()
....
    OSError: Command /Users/name/foobar/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 2

Does anyone know what is causing this problem or how I can get around it. I have tried various versions of installing virtualenv and pip locally/globally to no avail.

This likely means you don't have pip installed in your system python environment. virtualenv depends on pip , so it was trying to be helpful and install it for you (and failing, because it couldn't write to /Library/Python/2.7/site-packages ).

Try installing pip into your system python first (with sudo ):

$ sudo easy_install pip

After that, virtualenv should be able to work without sudo -ing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM