Matt Seymour

By default brew will give you access to the latest version of python via the brew install command. But what if you want to install a specific version?

The simplest option is to use pyenv it allows you to install python specific versions to your machine.

Usefully pyenv is available as a brew package:

brew install pyenv

Note: Read through the command line summary and caveats after installing. It will allow you to better configure your setup. For example I would rather make use of the "Homebrew directories rather than ~/.pyenv" to do this add the following line to your profile (.bashrc, .zshrc).

export PYENV_ROOT=/usr/local/var/pyenv

To enable auto complete also include:

if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi

Once installed you can now download and install the python specific versions you are looking for. To do this use the following commands:

pyenv install 3.4.4

If you are wanting to make this work with virtualenv you can set the python environment setting using the -p, --python flag.

virtualenv -p <path to python bin>

virtualenv -p /usr/local/var/pyenv/versions/3.4.4/bin/python
# or
virtualenv -p ~/pyenv/versions/3.4.4/bin/python