I'm adding Python 3.x support to my open-source project and want to add both Py32 and Py33 test environments to my tox.ini. I already have Py26 and Py27 tox environments that work fine and I just installed Python 3.3 from homebrew and got the Py33 tox environment working nicely.

The problem seems to be that homebrew doesn't have an obvious way to install both 3.3 and 3.2 and a somewhat extended Googling did not yield an answer.

What's the best way to do this that won't lead me into trouble further down the road? I'm happy to build from source if that's the best solution, have done that before with good success but don't want to break out the axe if a pocket knife will get the job done :)

I'm running OS X 10.8.4

3 Answers 3


The problem seems to be that homebrew doesn't have an obvious way to install both 3.3 and 3.2 and a somewhat extended Googling did not yield an answer.

— Try the following solution to install multiple Python 3.x versions with brew:

  1. Make sure you don't have any Python 3.x installed:

    brew uninstall python3

  2. Then cd into your brew directory, this is /usr/local normally:

    cd /usr/local

  3. Then list all the available Python 3.x versions in Homebrew:

    brew versions python3

  4. Then follow installation instructions for required Python versions from here.

  • Sweet! This gets it done :) Now I can use tox to test with all of Python 2.6, 2.7, 3.3, and 3.4 :)
    – scanny
    Jun 23, 2014 at 0:27
  • 6
    brew versions has been removed
    – wim
    Jun 9, 2015 at 4:53

The installation instructions referenced by @dimitry-cheremushkin have been changed and recommend using pyenv instead. Tox and Pyenv can be used together like this:

First we ensure we have pyenv installed:

$ brew update
$ brew install pyenv

Then we install all the needed python versions with pyenv. This might take time. See python.org/downloads for available versions.

$ pyenv install 2.6.9 && pyenv ... && pyenv install 3.5.0

In the directory of our setup.py, let us run pyenv local ... as below. It will create .python-version file that stores the versions to be used.

$ pyenv local 2.6.9 2.7.10 3.2.6 3.3.6 3.4.3 3.5.0

So, pyenv installed the Python distributions to a dir ~/.pyenv/shims. To let them to be found instead default Python, the dir must be prepended to the PATH environment variable. Even though more permanent solutions exist, the following does the trick for one terminal session:

$ eval "$(pyenv init -)"
$ echo $PATH

The following has been recommended to be run to ensure the shims have correct packages:

$ pyenv rehash

Now, let us assume the following tox.ini:

envlist = py26,py27,py30,py31,py32,py33,py34,py35

Finally we can run tox in all the environments:

$ tox
py26: commands succeeded
py27: commands succeeded
py30: commands succeeded
py31: commands succeeded
py32: commands succeeded
py33: commands succeeded
py34: commands succeeded
py35: commands succeeded
congratulations :)
  • 1
    I don't quite understand what .python-version is for. Why is it needed? Should it be committed to version control?
    – Flimm
    May 2, 2016 at 14:28
  • @Flimm The .python-version tells pyenv which python versions it should make available in the current directory and to which exact versions the shorthands like python or python3 should refer to. The first line defines the version to be used when python is called. If you expect the other developers to use pyenv to test the code in the repository, then I think you should commit .python-version too. May 7, 2016 at 16:20

One option is using MacPorts:

$ sudo port install python34 python35
$ python3.4 -V
Python 3.4.6
$ python3.5 -V
Python 3.5.3

You can also select which version should be used when running python3:

$ port select python3
Available versions for python3:
    python34 (active)
$ sudo port select python3 python35
Selecting 'python35' for 'python3' succeeded. 'python35' is now active.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.