python virtualenvwrapper bad interpreter

Viewed 8013

I recently upgrade from python 3.5 to python 3.6 (with brew on macOS). However virtualenvwrapper now seems to be broken and I get the error. A reinstall didn't help unfortunately.

mkvirtualenv:78: /usr/local/bin/virtualenv: bad interpreter: /usr/local/opt/python3/bin/python3.5: no such file or directory

I have VIRTUALENV_PYTHON=python3 set so the default is to install a virtualenv with python3.

3 Answers
  1. open the terminal use which python3.6 to show the path of python3.6
  2. open the file /usr/local/bin/virtualenv
  3. change the first line which starts with #! with the path of python3.6 before

For me, it was because there were spaces in some of the directory names and virtualenv did not parse the path correctly. To be safe, just remove spaces from the directory names and replace them with - or _ and it should work fine :)

Use: pip install --upgrade virtualenv

OR: sudo pip install -U --force-reinstall virtualenv

Related