Manage multiple versions of Python with pyenv

As of writing, macOS Catalina ships with Python 2.7.2 and Python 3.7.6, the latest version of Anaconda runs at Python 3.7.6 and the latest stable release of Python on is 3.8.4. Meanwhile, HomeBrew is offering 3.8.3 and a beta of 3.9 and 3.10; as well as several versions of Anaconda.

So, what should you install?

In short, pyenv, a utility that lets you easily switch between and install multiple versions of Python.

Install pyenv

Install XCode command line tools

xcode-select --install

Install Homebrew

copy the installation command from

/bin/bash -c "$(curl -fsSL"

Install pyenv

brew install pyenv

Install python

list available versions to install

pyenv install --list

install the version you require

pyenv install 3.8.3

Edit your .zprofile

Add the following lines to your .zprofile

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"

This script initialises pyenv

Re-run your .zprofile

. ./.zprofile

Now test your python installation

which python
# /Users/johndunning/.pyenv/shims/python
python --version
# Python 3.8.3
pip --version
# pip 19.2.3 from /Users/johndunning/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pip (python 3.8)

Going forward

use pyenv to manage your python and anaconda installations

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.