Install Python On Mac Catalina

Install Python On Mac Catalina

Python on a Macintosh running Mac OS X is in principle very similar to Python on any other Unix platform, but there are a number of additional features such as the IDE and the Package Manager that are worth pointing out. Getting and Installing MacPython ¶. Mac OS X 10.8 comes with Python 2.7 pre-installed by Apple. After installing Anaconda to its default location with Mojave, I've found that the upgrade to Catalina moves the 'anaconda3' folder to your Desktop Relocated Items Security anaconda3. It seems Catalina's security settings may not allow applications to install directly under the user directory anymore. 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 Mac laptop with OS Catalina installed. 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. Macos 10.14.6 Mojave, Xcode 11.0, right before the launch of macos Catalina 10.15. Newly purchased Macbook Pro. Failure on pip install psycopg2, which is, basically, a Python package getting compiled from source. I have already carried out a number of the suggested adjustments in the answers given here.

In this chapter, you learn how to install Python on MacOS, Windows, and Linux. We will look at multiple installation methods per platform and discuss what I think is the best option to choose from.

Most of the time, it’s not advisable to use the official installer from the python.org website. Instead, it’s better to go for the version packaged by your operating system. The advantage of OS supplied version, is that you’ll get automatic updates.

Install Python on Windows

There are three methods you can choose from on Windows.

Using The Microsoft Store

Microsoft hosts a community release of Python 3 in the Microsoft Store. This is the recommended way to install Python on Windows because it handles updates automatically and can be uninstalled easily too.

To use this method:

  • Pick the newest version and install it

With the official installer

You can download a Python installer from the official Python download website too. This method does not give you automatic updates, and I would recommend it only if you don’t have access to the Microsoft store.

Inside WSL

If you’re familiar with Windows Subsystem For Linux, you may want to consider that option too. It’s what I use myself, and I’m truly loving it. It offers me the advantages that Windows has to offer (mainly great hardware support), while still enjoying Linux which is, in my opinion, the best platform for Python development.

To install in WSL, you’ll first need to install WSL itself. Go for WSL2 if you can. It’s much better. After that, simply follow the Linux installation instructions below!

Installation on MacOS

On most versions of MacOS before Catalina, a distribution of Python is already included. Unfortunately, it’s almost certainly an old version, Python 2.7. Luckily, there are two ways to install Python 3 on a Mac with ease.

Homebrew

First and foremost, I recommend looking into Homebrew. It allows you to install almost anything easily. The added benefit is that it’s also easy to upgrade to newer versions later on.

Once you are up and running with homebrew, installing Python on MacOS is as easy as:

Official installer

Alternatively, you can download an installer from the Python download website. The downside to this approach is that you won’t get automatic updates.

Install Python on Linux

There are several ways to install Python on Linux, that is, if you need to install it at all!

Check what’s installed first

Most Linux distributions include Python. Many will include both Python 2 and Python 3.

If you enter python --version on the command line, you’ll see the version number. It’s probably version 2.7:

You don’t want Python 2, but some OS’es still ship with it, unfortunately.

Now try python3 --version. If you get a “command not found,” you need to install Python 3. If your output looks similar to this, you’re in luck:

Using a package manager

Depending on the distribution of Linux you are running, you can install Python with the default package manager: Yum, APT, etcetera. You’ll need to find out for your specific Linux distribution which package manager is used and how to use it.

If you’re on Ubuntu, Linux Mint, or Debian, you can install using apt:

Homebrew

Another interesting option for Linux is using Homebrew. That’s right, the package manager for Macs also works on Linux.

The major advantages of using Homebrew:

Install Python On Mac Catalina Os

  • You’ll get the latest version of Python, instead of the version your OS shipped with
  • You don’t need root access to your system. All the software installed with Homebrew is installed in your home directory

I find myself using Homebrew more and more while working under Linux — give it a try!

Python in your browser

If you don’t feel like installing Python, or you are unable to install it for whatever reason, I’ll offer an alternative too: you can use Python right from your browser; no installation necessary!

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:

Python

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:

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:

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.

Install Python On Mac Catalina Operating System

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:

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:

Install Python 2.7 Mac Catalina

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