Restoring Python 2 on macOS 12.3 and Higher

Restoring Python 2 on macOS 12.3 and Higher

In just a couple of straightforward commands

Just a very quick post today! I will be writing some more detailed posts about various topics soon, but things have been so busy over at CircleCI recently.

Apple recently released macOS 12.3 and, in the process, removed Python 2 from macOS entirely. Python 2 has been deprecated, and EOL, for several years now (Homebrew deleted the formula some time ago), so the removal of it from the base OS is no real surprise.

As always, I would encourage everyone to migrate to Python 3 for better long-term support, but if you have scripts that absolutely must use Python 2, then this can be added back to macOS in a couple of commands.

Adding Python 2 back to macOS

The Python project still hosts the final Python 2 macOS installer package, so we can simply download and install this to restore Python 2 to macOS. It is simple and quick to do this entirely from the command line:

curl -O
sudo installer -pkg python-2.7.18-macosx10.9.pkg -target /


Screenshot 2022-04-14 at 10.49.13.png

It is as simple as that. Python 2 will now be available again via the python command and will live happily side by side with the system Python 3 installation (which is the python3 command)

This also works in CircleCI, where Python 2 is no longer available from Xcode 13.3 onwards:

Screenshot 2022-04-14 at 10.53.22.png

Happy Building!