How to install Python 2 on Mac OS 12.3 and higher

Photo by Sigmund / Unsplash

Python is a programming language widely used for building software and web applications. It is supported by major operating systems, especially MacOS, where version 2 was installed with the operating system by default.

Starting version 12.3 of Mac OS Monterrey,  Python 2 was removed from macOS, and developers are encouraged to use Python 3 or other programming languages.

There are still many python scripts running on Python 2.7 that can't be upgraded for various reasons, so you might need to install it.

Removed in Homebrew

If you try to install Python 2 from Homebrew, it will not work because the package has been removed:

Installation error of Python 2 using Homebrew.

Fortunately, you can get the latest version of Python 2 from the official download site.

Download and install Python 2

At the moment I'm writing this, the latest version is 2.7.18. Go to the download link and select the MacOS version.

Download Python 2 for MacOS.

After the download, install the software by following the installation guide.

You can test that the installation succeeded by opening a new terminal and type python.

Python 2 is installed on the computer.

Install with pyenv

Another installation alternative is to use pyenv, a version management tool for Python. You can install many versions of Python on the same computer and switch between versions depending on the project's requirements.

The GitHub page provides a good installation guide. You can follow it and give a star to support the maintainer.

GitHub - pyenv/pyenv: Simple Python version management
Simple Python version management. Contribute to pyenv/pyenv development by creating an account on GitHub.

Follow me on Twitter or subscribe to my newsletter to avoid missing the upcoming posts and the tips and tricks I occasionally share.