Install Python Mac Catalina

MacOS 10.15 (Catalina) now ships with Python3 but I would recommend installing a second version as not to “upset” the OS native shipped version. The book recommends Python 3.6.6 (at time of writing), I have based this post on Python 3.7.7 (I recommend not going to a higher version as Pygame Zero still has some install issues on the latest. Build pyenv Python versions on macOS Catalina 10.15. After installing a python version, you also need to install your preferred python venv handler(-s) in every.

Posted on October 21, 2019 by Paul

Updated 11 February 2020

In this article, I will show you how to install OpenCV 4 with Python 3 on macOS Catalina.

There is also a video version of this tutorial:

MacOS comes by default with Python 2.7 which, at this point, receives only bug fixes and will be EOL by 2020. Python 3.x is the future and it is supported by all major Python libraries. In this tutorial, we’ll use the Python 3.8.

Start by installing the Command Line Tools for macOS. Please note, that you will need the Command Line Tools even if you’ve already installed Xcode. Open a Terminal and write:

Install Python Mac Catalina Download

Once the Command Line Tools are installed, we can install Python.

The official installer of Python is a pkg file that will start a GUI installer which will guide you through the installation. You can also check the video version of this tutorial if you want to see how I did it.

As a side note, you can have multiple Python 3 versions installed on your macOS machine. If this is the case, you can select which version you want to use by specifying the version number, e.g.:

or:

After the above, you can invoke Python 3.8 using the python3.8 command. python3 will also invoke the latest installer version of Python 3. This is what I see if I run python3.8 on my machine:

Install Python Mac Catalina Operating System

Next, let’s follow best practices and create a new Python environment in which we can install NumPy and OpenCV:

At this point, your prompt should indicate that you are using the work environment. You can read more about Python environments in the documentation.

Once an environment is activated, all the install commands will apply only to the current environment. By default, if you close your Terminal, the environment is deactivated. If you want to be able to use it, use the source work/bin/activate command.

We can install NumPy and OpenCV with:

Please note that the above will install the slightly older OpenCV 4.1, latest binary version doesn’t seem to work on macOS Catalina!

As a side note, when you are in a new environment you can use python to invoke the Python interpreter, no need to use the version number.

At this point, you should have OpenCV 4 and Python installed on your Mac. We can write a small test program that will print the OpenCV version, load an image from the disk, convert the image to gray and show the result. Start by downloading the next image:

Save it as clouds.jpg. In the same folder where you’ve saved the above image, create a new file demo.py and write the next code:

Mac

Run the code with:

(You can close the two windows by pressing ESC!)

You should see something like in the next figure. By default, the last image (the gray one) will be over the first one. You need to move the window in order to see both images:

If you want to learn more about OpenCV and Python I would recommend reading OpenCV with Python Blueprints by M. Beyeler:

or, OpenCV with Python By Example by G. Garrido and P. Joshi:


Install Python Mac Catalina Free

Maria Campbell provides a post on installing the latest version of Python on Mac OS Catalina and overriding the old default pre-installed version. And it even uses Homebrew and not some gnarly steps.

I finally did it. I successfully installed Python version 3.7.7 via Homebrew on my Maclaptop with OS Catalinainstalled.

For those of you that still might be trying to figure out how to do this, I will walk you through.

The reason why I was eager to make sure that I had the latest version installed was because I am working on publishing (open-source) teaching-related documentation on Read The Docs, and I need to have Python installed in order to be able to install the programs necessary to publish there.

The default 2.7.17 version of Python was retired this past January 2020. I had tried back then to replace it with Python 3+, but was unsuccessful at the time.

They key appears to be also adding the following at the bottom of the .zshrc file to update the path to the newly installed version of Python via Homebrew:

Install Python Mac CatalinaPythonPython

See all the steps in the blog post here and podcast here.