macOS – Installing Python

I have done a fresh installation. I am not in favor of updating an OS. When updating the OS, traces are always left behind. I also like that I have a completely clean system and I also like to implement it. And by doing this more often it keeps me sharp on changes and procedures. After the installation of macOS 10.15 Catalina, a number of things have changed apparently also regarding Python.

macOS 10.15 Catalina Deprecates UNIX Scripting Languages

The older Python language, version 2.7, is being deprecated in macOS 10.15 Catalina and won’t be included in macOS 10.16. The same goes for other UNIX scripting languages. Let’s focus on Python first because of its nuances of versions.

 

 

The Python Case

This is not as bad as it sounds. Python 3.0 was released way back in December, 2008. Python 3.0 made a fundamental break from some bad design choices in Python 2.x, which culminated in version 2.7. Accordingly, a lot of complex Python 2.x code just won’t run with Python 3.x and has to be rewritten.

But Apple never updated the default install in macOS and left Python at version 2.7 for longstanding backwards compatibility. For 10 years, it has been left up to users to install Python 3.x, a version which can be installed alongside of 2.7. One way to look at this is that so long as users who needed Python 3.x could easily install it, there was no need or Apple to continuously manage a new version in each release of macOS starting in 2009.

Apple’s Deprecation Statement

Knowing all this, we can now put Apple’s developer notes for 10.15 Catalina into proper perspective.

Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. Future versions of macOS won’t include scripting language runtimes by default, and might require you to install additional packages. If your software depends on scripting languages, it’s recommended that you bundle the runtime within the app. (49764202)

Use of Python 2.7 isn’t recommended as this version is included in macOS for compatibility with legacy software. Future versions of macOS won’t include Python 2.7. Instead, it’s recommended that you run python3 from within Terminal. (51097165)

 

The bottom line is that you’ll still be able to install UNIX scripting packages like Perl, Python and Ruby into future versions of macOS, just as you could in the past. They just won’t be included by default in macOS 10.16 and beyond.

Install Xcode and Homebrew

We will use the package manager Homebrew to install Python 3.0. Python depends on Apple’s Xcode package, so run the following command to install it:

xcode-select --install

Click through all the confirmation commands (Xcode is a large program so this might take a while to install depending on your internet connection). Next, install Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Note: You can also find this command on the homepage of the Homebrew website. It’s easiest to copy and paste since it’s a long command. To confirm Homebrew installed correctly, run this command:

brew doctor

And it will say:

Your system is ready to brew.
Install Python 3

To install the latest version of Python, run the following command:

brew install python3

Now let’s confirm which version was installed:

python3 --version

And it will show you the version:

Python 3.7.4

To open a Python 3 shell from the command line type python3:

python3

This will start Python3:

Python 3.7.4 (default, Jul 9 2019, 18:13:23)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

When you want to exit, type exit() and then Return or Ctrl-D (the Control and D key at the same time). That’s it!

The advantage of this is that most Mac customers never use UNIX scripting languages, let alone drop into a UNIX shell. Apple won’t have to ship macOS with older versions of these languages. And I’m guessing it’s a security consideration.

So it’s not really a big deal. Apple isn’t abandoning the UNIX underpinnings of macOS. Experienced UNIX users will be able to install what they need.I predict, however, that one day in late 2020, a scientist will take delivery of a new Mac, open a Terminal window, and find Python (… Perl … Ruby) missing. There will be wailing and gnashing of teeth.

 

Scroll to Top