Nov 05,
2015

Virtualenvwrapper and Python 3

This is mostly a note for my future self as for sure in a couple of months I'll forget about it.

According to the documentation, current version of virtualenvwrapper is tested to work with Python 3.4, but it's not very clear on how you need to configure it, at least after a cursory glance. Well, it follows the VIRTUALENVWRAPPER_PYTHON environment variable if defined, so after declaring the path to a Python 3 interpreter, it should start working (the path depends on the OS/environment, so the following should be modified accordingly by the reader):

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3

Another thing to note is that the virtualenvwrapper.sh script seems not to be re-entrant, at least with my configuration. My quick workaround is to evaluate it only once:

if [[ -z "$VIRTUALENVWRAPPER_HOOK_DIR" && \
      -e /usr/local/bin/virtualenvwrapper_lazy.sh ]]; then
   source /usr/local/bin/virtualenvwrapper_lazy.sh
fi

I should probably check if someone has filed a bug report.