Install Python on macOS 11 M1 (Apple Silicon) using pyenv

A fresh Mac and its default Python

macOS 11 comes with a default version of python2, which is now obsolete in favor of python3. Python2 reached end of life in January 2020.

We are certainly do not want to touch macOS’s default python2 and will leave it as it is. Let’s install pyenv to manage multiple versions of Python.

Install pyenv on macOS 11 (Apple Silicon)

There are two ways to install pyenv on macOS:

  • Via Homebrew: this is the quickest way. Unfortunately I could not make pyenv works as expected on a fresh macOS 11 (Apple Silicon).
  • Git checkout: pyenv team has documented the install process in details here. However, when I followed that step by step and applied on my new macOS 11 (M1), it did not work. After serveral hours tweaking, here's how I managed to get the pyenv to work with Git check out installation.
  1. Clone the pyenv repo into your home folder:

2. Edit your .zshrc and add the following lines at the bottom of the file (macOS 11 comes with zsh as the default shell)

3. Quit your terminal and reopen it. Now pyenv should be activated and you can start to install some Python.

My macOS 11 (Big Sur, Apple Silicon) system info before install Python

Install the Python build dependencies for macOS 11

pyenv suggests that before install any version of Python, we need a Python build environment for Mac. Make sure you have Xcode Command Line Tools ( xcode-select --install) and Homebrew on your system. Then:

To install Homebrew on a fresh macOS 11 Big Sur M1, check out this guide.

Install Python 3.9 on macOS 11 M1 (Apple Silicon)

pyenv install Python 3.9.4 seamlessly on Mac M1 and everything works out of the box.

Install Python 3.8 on macOS 11 M1 (Apple Silicon)

You need to use Homebrew’s patch to install Python 3.8 with pyenv. For the complete details, please read pyenv issue 1768.

If you want to jump right way to the answer, this comment is enough:

The patch for 3.8.3 applies to 3.8.6 without any issue:

Install Python 3.7 on macOS 11 M1 (Apple Silicon)

Python 3.7.10 installed smoothly without any patch from Homebrew:

Install Python 3.6 or below on macOS 11 M1 (Apple Silicon) with pyenv

Other Homebrew patches are available here: 3.6.1, 3.7, 3.8.3, 3.8.7, arm64-3.9 A quick remind that 2.7 reached end of life (EOL) last year on 2020-01-01, 3.6 will reach EOL by the end of this year 2021. They shouldn't be used at all.

Post-install verification Python 3.7, 3.8 and 3.9

List all Python versions managed by pyenv:

Set the default python to 3.8.6, cause that's what I want when typing python on the terminal

Verify pyenv shims is activated on the PATH:

All python environments are natively installed with arch=arm64 on Apple Silicon (M1 Big Sur)

Other guides

Install Homebrew on macOS 11 (Apple Silicon)

Install and configure Git on macOS 11 Big Sur (Apple Silicon)

--

--

Software Engineer, toward Mars.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store