Skip to content

Instantly share code, notes, and snippets.

@girip11
Last active July 2, 2022 13:26
Show Gist options
  • Save girip11/a962fcb0efe606f5faa68b0ea8a388dd to your computer and use it in GitHub Desktop.
Save girip11/a962fcb0efe606f5faa68b0ea8a388dd to your computer and use it in GitHub Desktop.
Python 3.8 installation on Mac OS M1 Monterey

Python 3.8.13 installation on Mac M1

  • Install the following
# install pyenv using brew if not already installed
brew install pyenv
brew install openssl readline sqlite3 xz zlib

# Install python 3.8.13
PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA="openssl@3" pyenv install 3.8.13

NOTE: Python 3.8.13 supports Mac M1 out of the box.

In the same way as above, we could install Python 3.9 and 3.10. Also I didnt find any issues in installing Python 3.7.13 as well.

Installing Versions earlier to 3.8.13 using pyenv

  • This requires applying patch. Command looks like below.
# Before using the command just find out the correct link to the path
# https://github.com/Homebrew/formula-patches/tree/master/python
pyenv install --patch 3.8.12 <<(curl -sSL https://raw.githubusercontent.com/Homebrew/formula-patches/113aa84/python/3.8.3.patch\?full_index\=1)

Install using GCC

This is not recommended but I came across this as a technique to install Python 3.8.12 or earlier minor versions of 3.8. This uses the GCC compiler.

brew install gcc
CC="$(brew --prefix gcc)/bin/gcc-11" PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA="openssl@3" pyenv install 3.8.12

But there might be issues when we have to use installed packages. I havent used this technique, just documenting it incase I might require in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment