Install pyenv on MacOS
I’m a big fan of pyenv, a slick way to manage Python on UNIX or Linux systems. It can be installed on MacOS systems, but it’s not quite as straight-forward.
Preparation
- Install homebrew
- Install prerequisite packages:
brew install readline xz
- Download and install the latest CommandLineTools from the Apple Developer site.
Install
- Install pyenv with brew:
homebrew install pyenv
- Install a Python version:
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.7.1
- Update pip:
pip install --upgrade pip
- In step #2, substitute 3.7.1 for whatever version of Python you wish to install with pyenv.