2

I've got several versions of python on my mac. I woud like python3 to be the default version and also would like to use virtualenv and virtualenvwrapper.

So, I've put an alias in my ~/.zshrc

alias python='python3'

I've also added the following to my ~/.zshrc

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

However, when I run mkvirtualenv i get the following error:

▶ mkvirtualenv cv
mkvirtualenv:79: /usr/local/bin/virtualenv: bad interpreter: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Ver: no such file or directory

I get the same error even if I pass the version of python:

▶ mkvirtualenv -p /usr/local/bin/python3 cv
mkvirtualenv:79: /usr/local/bin/virtualenv: bad interpreter: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Ver: no such file or directory

Some more command line output showing versions and what I've installed:

▶ python --version
Python 3.5.0

~                                                                                                                                                                                  
▶ pip3.5 install virtualenv
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages

~                                                                                                                                                                                  
▶ pip3.5 install virtualenvwrapper
Requirement already satisfied (use --upgrade to upgrade): virtualenvwrapper in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): stevedore in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): six>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): pbr<2.0,>=1.6 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): argparse in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from stevedore->virtualenvwrapper)

~                                                                                                                                                                                  
▶ echo $VIRTUALENVWRAPPER_PYTHON
/usr/local/bin/python3

This is what /usr/local/bin/virtualenv has

▶ more /usr/local/bin/virtualenv
#!/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
# EASY-INSTALL-ENTRY-SCRIPT: 'virtualenv==12.0.5','console_scripts','virtualenv'
__requires__ = 'virtualenv==12.0.5'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
    sys.exit(
        load_entry_point('virtualenv==12.0.5', 'console_scripts', 'virtualenv')()
    )

Update

~                                                                                                                                                                                  
▶ virtualenv --no-site-packages --distribute -p /usr/bin/python3.3 ~/.virtualenvs/pywork3
zsh: /usr/local/bin/virtualenv: bad interpreter: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Ver: no such file or directory
Omnipresent
  • 29,434
  • 47
  • 142
  • 186

1 Answers1

3

Use the command pyvenv with python 3.

Example:

pyvenv venv
source venv/bin/activate
kamy22
  • 143
  • 5
  • Did you try to reinstall it? [Similar topic](http://stackoverflow.com/questions/22238170/trouble-using-mkvirtualenv-after-installing-os-x-mavericks) – kamy22 Sep 24 '15 at 18:35
  • I've reinstalled several times but no help – Omnipresent Sep 24 '15 at 18:41
  • output of the reinstallation process. https://gist.github.com/Omnipresent/d7c82568b557a1727caa – Omnipresent Sep 24 '15 at 18:48
  • Can you reinstall it like this : `sudo brew install -y curl && curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | sudo python sudo easy_install pip sudo pip install virtualenv virtualenv ve` – rakesh Sep 24 '15 at 18:51
  • that has the same effect. I believe the problem is that `/usr/local/bin/virtualenv` references 2.7.3 – Omnipresent Sep 24 '15 at 18:57
  • Can you try this and let me know the output: virtualenv --no-site-packages --distribute -p /usr/bin/python3.3 ~/.virtualenvs/pywork3 – rakesh Sep 24 '15 at 19:04
  • This helped me for what it's worth – rorykoehler Mar 17 '16 at 05:27