I want to run tests with multiple Python versions on OS X 10.11, including:
I want to run the tests via tox
so tox needs to be able to find them. Sadly it seems that brew doesn't want to install 3.4 since they added 3.5 and I obviously do not want to remove 3.5 one.
In those situations, the Python Version Manager(pyenv) is a great tool to use, allowing you to install multiple versions of Python and switch between them as you see fit.
If you wish to use multiple versions of Python on a single machine, then pyenv is a commonly used tool to install and switch between versions. This is not to be confused with the previously mentioned depreciated pyvenv script. It does not come bundled with Python and must be installed separately.
You can have both versions installed at the same time.
Install that version using "make install". Install all other versions using "make altinstall". For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute "make install" in your 2.6 build directory and "make altinstall" in the others.
pyenv
is the thing you want. It works very very well:
pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well. This project was forked from rbenv and ruby-build, and modified for Python.
https://github.com/pyenv/pyenv
Install it via Homebrew:
$ brew update $ brew install pyenv
It handles the download, compilation, and installation of various pythons for you, e.g.:
$ pyenv install 3.7.2
It can show you which versions you've installed, and which is active:
$ pyenv versions system 3.6.7 * 3.7.2
When you're in a new project directory, just tell pyenv which python version to use there:
$ pyenv local 3.6.7 # Because e.g. tensorflow isn't compat. with 3.7 :-(
You can set a 'default' version everywhere else:
$ pyenv global 3.7.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With