Install Python

You can download the Python for free at https://python.org/, and there are versions for Linux, macOS, and Windows.

Install Python with Homebrew

To set up Python for Mac, I use Homebrew. Firstly, check if you have Homebrew

$ brew --version

First, we’ll install Xcode, which Homebrew requires, and then Homebrew.

Install Xcode

$ xcode-select --install

Install Homebrew

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

Install Python

brew install python

Upgrade Python

To upgrade Python with Homebrew, we can use the following code.

brew upgrade python

Set Python3 as a default python version on MacOS

Firstly we add this command

ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python

Close the current terminal session and open a new terminal window (not tab). Run this:

python --version

We will get this

Python 3.9.0