Install pyenv on MacOS 10.14.3

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

  1. Install homebrew
  2. brew install readline xz
  3. Download and install the latest CommandLineTools from the Apple Developer site.

Install

  1. homebrew install pyenv
  2. CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.7.1
  3. pip install --upgrade pip

In step #2, substitute 3.7.1 for whatever version of Python you wish to install with pyenv.