Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duonghuuphuc/7d6fea245b60a262e96f3b2db63f5ea6 to your computer and use it in GitHub Desktop.
Save duonghuuphuc/7d6fea245b60a262e96f3b2db63f5ea6 to your computer and use it in GitHub Desktop.
Install Python3 on macOS 10.15 and later

Install Python3 on macOS 10.15 and later

This tutorial will show you how to install Python3 on a macOS system. To demonstrate the installation process, I will present the steps on macOS Catalina (Version 10.15). Instead of installing Python3 via the installer from the Python website, this tutorial will use brew which is the most popular Package Manager for macOS.

1/ Install brew

Installing brew on your system is straightforward, you just need to copy-and-paste the following command to the Terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2/ Install Python3 with brew

We first install Python3 via brew command, and then we define location of the bin directory of the newly installed Python3 to notify the system to know where to look for the installed Python packages.

Install Python3 via brew:

brew install python3

Update the zsh profile by creating a new ~/.zshrc, or open the current one:

nano ~/.zshrc

Insert the following lines of code into the first line of ~/.zshrc:

# Configure PATH for Python 3
export PATH="/usr/local/opt/python/libexec/bin:$PATH"

To make sure that you have correctly installed the Python3 to the system, you need to restart the Terminal (quit and re-open the Terminal), and then execute the following commands:

which python3
(Expected output: /usr/local/bin/python3)
python --version
(Expected output: Python 3.9.10)

4/ Troubleshooting

  • If you get this error message Failed during: /usr/local/bin/brew update --force --quiet when installing Homebrew on macOS, you should execute the following command with sudo level: sudo chown -R $(whoami) $(brew --prefix)/*

5/ Further reading

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