Make virtualenvwrapper use brew -ed python instead of system python on OS X 10.9


Why is $ mkvirtualenv test

using system python (v2.7.6) instead of brew -ed python (2.7.8) and how do I configure virtualenvwrapper to use the python I want?

System Setup

I am using OS X 10.9.5 with python home installation (v2.7.8). I have a system installation of virtualenv and virtualenvwrapper. My shell is ZSH via oh-my-zsh using the virtualenvwrapper plugin (although I tried to pull the plugin and load manually and I get the same behavior).


This 2.7.8 is the python interpreter I get from the shell

$ echo $PATH

$ which python

$ python
Python 2.7.8 (default, Aug 24 2014, 21:26:19)


I have the following environment installed at the top of my .zshrc (prior to getting the virtualenvwrapper file) and mapped them all to the output $ printenv

to confirm they are installed correctly

export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Projects/Python
# this is the location shown above to be v2.7.8
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python 
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv 
export PIP_DOWNLOAD_CACHE=$HOME/.pip/download_cache


Despite the correct $ PATH and explicit override to use the python interpreter, I know that v2.7.8 any mkproject gets the system python by default:

$ mkvirtualenv test

(test)$ python
Python 2.7.6 (default, Mar 18 2014, 15:05:23)



I found frenzy (in that it seems like it won't change anything) the workaround

$ mkvirtualenv -p `which python` test

(test)$ python
Python 2.7.8 (default, Aug 24 2014, 21:26:19)


So why in the world are these environment variables not being used, even though they are set and have a clear ability to work as shown in the work?


source to share

1 answer

By default, it virtualenv

will use the python binary it was installed with, not the python binary that appears first in the path.

virtualenv --help
  -p PYTHON_EXE, --python=PYTHON_EXE
                        The Python interpreter to use, e.g.,
                        --python=python2.5 will use the python2.5 interpreter
                        to create the new environment.  The default is the
                        interpreter that virtualenv was installed with


Your best virtualenvwrapper

bet is probably to uninstall and then reinstall it using pip living in your Python installation directory.



All Articles