I finally needed some Python to do some OpenCV work on my Mac. And although Mac nowadays comes with Python pre-installed, it's not the exact version we are looking for.
Open a terminal and run the
python command to demonstrate that.
This should now return version 2.
So how can we ensure we have the latest Python version available on our Mac system?
Mac installing Python 3
The easiest way to install Python 3 is to use Homebrew. If you haven't had Homebrew installed yet, check out this article explaining how to set up Homebrew on your Mac.
With Homebrew installed, we can install Python, which will install the latest stable (at the time of writing 3.9).
brew install python
And once that is done, we should run the
python3 command to see if our version matches.
However, it's a bit of a mission to type the number three after Python manually.
To fix that, we can add a new alias to link
python3 to the command
I'm using Zsh, so I have a
~/.zshrc file, open this file and add the following line.
If you restart your terminal, you should run just the
And that's it. We now have the latest version of Python installed on our MacOs system.