Ignore the top link on Google which takes you a process of using pyenv
. It’s not until you’ve spent several hours painstakingly following the instructions that you find out it’s for some shell I’ve never used called Fish.
Just do:
- brew install python2
- brew install python3
- then to use Python 2, use
python2
and for Python 3, usepython3
i.e. DON’T DO:
- use
pyenv
- make sure
brew
is up to date:brew update && brew upgrade pyenv
pyenv install 3.7.2
pyenv install 2.7.14
- Set the global version with
pyenv global 3.7.2
- Set local versions (e.g. for legacy projects) with
pyenv local 2.7.14
Notes:
- latest version of Python: https://www.python.org/downloads/
- Blog post on
pyenv
: https://weknowinc.com/blog/running-multiple-python-versions-mac-osx
Problems:
ERROR: The Python zlib extension was not compiled. Missing the zlib?
brew install readline xz
did not work for me.
This worked though:
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 2.7.14
More:
https://github.com/pyenv/pyenv/wiki/common-build-problems