Previous versions used homebrew to install the various versions. As suggested in the comments, it's better to use pyenv
instead. If you are looking for the previous version of this document, see the revision history.
$ brew update
$ brew install pyenv
$ pyenv install 3.5.0
$ pyenv install 3.4.3
$ pyenv install 3.3.6
$ pyenv install 3.2.6
$ pyenv install 2.7.10
$ pyenv install 2.6.9
$ pyenv versions
* system (set by /Users/bouke/.pyenv/version)
2.6.9
2.7.10
3.2.6
3.3.6
3.4.3
3.5.0
Then, when you need a certain version:
pyenv local 3.5.0
This will create a file .python-version
, so pyenv will remember the Python version for this directory. This works also nice with tox
, as you can activate many Python version at once. See the pyenv documentation for more information.
See also Using tox and pyenv for testing and development for a more detailed how-to.
pyenv install 3.7.2
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.2.tar.xz...
-> https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
Installing Python-3.7.2...
python-build: use readline from homebrew
BUILD FAILED (OS X 10.14.3 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/g_/9zn58k_16m50w1z3tqvq65xr0000gn/T/python-build.20190214115852.93619
Results logged to /var/folders/g_/9zn58k_16m50w1z3tqvq65xr0000gn/T/python-build.20190214115852.93619.log
Last 10 log lines:
File "/private/var/folders/g_/9zn58k_16m50w1z3tqvq65xr0000gn/T/python-build.20190214115852.93619/Python-3.7.2/Lib/ensurepip/main.py", line 5, in
sys.exit(ensurepip.main())
File "/private/var/folders/g/9zn58k_16m50w1z3tqvq65xr0000gn/T/python-build.20190214115852.93619/Python-3.7.2/Lib/ensurepip/init.py", line 204, in main
default_pip=args.default_pip,
File "/private/var/folders/g/9zn58k_16m50w1z3tqvq65xr0000gn/T/python-build.20190214115852.93619/Python-3.7.2/Lib/ensurepip/init.py", line 117, in _bootstrap
return _run_pip(args + [p[0] for p in PROJECTS], additional_paths)
File "/private/var/folders/g/9zn58k_16m50w1z3tqvq65xr0000gn/T/python-build.20190214115852.93619/Python-3.7.2/Lib/ensurepip/init.py", line 27, in _run_pip
import pip._internal
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1