You can download the Python for free at https://python.org/, and there are versions for Linux, macOS, and Windows.
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
To upgrade Python with Homebrew, we can use the following code.
brew upgrade python
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