How to Upgrade Your Mac to Python 3 [2017 Update]

Python featured image.

Python logo. Note, this article is a significant revision to the original article from July 23, 2014, “How to Upgrade Your Mac to Python 3.


________________________________

1. Apple Only Provides Python 2.7 in macOS

Python 2.x is installed in macOS by default. Even macOS 10.13 High Sierra has Python 2.7.4 as its only version.

As the Python website says, “Python 2.x is legacy, Python 3.x is the present and future of the language.” Briefly, in order to move forward technically as a language, the creator, Guido van Rossum, needed to make some significant internal changes. To do this, backwards compatibility had to be compromised. As a result, the 3.x version can’t be depended on to run 2.x scripts.

Python 2 will reach end of life (EOL) in the year 2020..

So should you ever be using 2.7? Not unless you absolutely have to and accept that you’ll have to rewrite your code at some point. In the past, the Python.org site said:

Firstly, if you’re deploying to an environment you don’t control, that may impose a specific version, rather than allowing you a free selection from the available versions.

Secondly, if you want to use a specific third party package or utility that doesn’t yet have a released version that is compatible with Python 3, and porting that package is a non-trivial task, you may choose to use Python 2.7 in order to retain access to that package.

Alternatively, if you’re a newbie to the language and/or your class instructor insists that you begin by learning 3.x, then you’ll need to install it on your Mac. It’s particularly easy to do because 1) There’s an macOS installer package that does all the work and 2) it includes a basic IDE, and 3) you can still run both versions, so there’s no penalty to installing 3.6.x.

2. Where Can I Get Python 3.6.x?

Go to the Python website’s download page. It should auto-detect that you’re on a Mac. You’re probably wanting 3.6.2 (as of August 2017). It’ll look like this:

Python download page.
Python download page.

3. What do I Need to Know Before Installing?

If you’ve already downloaded a previous version of Python 3.x, the installer will create a new directory with new link called Python3.6. You won’t have to delete any other version.

4. Proceeding With the Installation

You’ll be downloading a macOS package file called “python-3.6.2-macosx10.6.pkg” to your downloads folder. (The 10.6 embedded in the file name means you need at least macOS Snow Leopard to run it. That means everything from 10.6 Snow Leopard up to and including 10.13 Sierra.)

When you double-click this file, it will launch the package’s installer, and you’ll see this:

Python's Installer Package Welcome
Python’s Installer Package Welcome

There are several steps. Walk through the installer by reading the package notes and agree to the license terms. It will install on your boot drive by default, but you’ll be given a chance to change the install location. Finally click on Install. You’ll be asked for an administrator password because the macOS Library is written to. The install will take only a minute or so.

When the installer is finished, it will have installed Python 3.6 in this directory.

/Library/Frameworks/Python.framework/Versions/3.6/

There will be a link to run the Python 3.6 executable here:

/usr/local/bin/python3.6 

The above points to:

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6

Finally, to run Python 3.6 interactively in the shell, type this on the command line:

> python3.6
Python 3.6 in shell
Python 3.6 in shell

You don’t need to type the full path because it’s already in your shell’s path. (You can see your default paths with > echo $PATH.)

5. How Do I Run the Older 2.7 Version?

To get to the 2.7 version, you can, type on the command line:

> python

6. Using the Basic IDE, Called IDLE, That Came With the Installation

If, in the Finder, you go to /Applications/Python3.6, you’ll find the IDE called IDLE.app. This is a macOS app. If you don’t want to work on the command line, you can use this IDE to write and save your code. Documentation is found under the Help menu “IDLE Help.”

First launch the IDLE app. It will launch in the shell. Then, to get to the edit window in IDLE, go to the app’s menu bar, and select File > New. Here’s the start of some new code, partially written.

The IDLE edit window.
The IDLE edit window.

Also, in the /Applications/Python3.6 folder is a file called ReadMe.rtf.  You should read that.

7. Where Can I Learn More?

There is a boatload of friendly information about Python at their website. It’s a beautifully laid out site.

If you’re in a learning mode, here are some good books:

1. Absolute beginner with with programming a computer. “Python Programming” by Michael Dawson.

2. For those who know a little programming. “Python Programming” by John Zelle.

3. For experienced programmers who want to learn Python. “Learning Python” by Mark Lutz. This book covers both 2.x and 3.x.

4 thoughts on “How to Upgrade Your Mac to Python 3 [2017 Update]

  • Hey, guys. I know you are Unix experts. And there are always other and/or more advanced ways of doing things. So thanks!

    But in this case the emphasis was on the student who just wants to get started coding fast. Down the road, the student will learn a lot more and embrace new tools.

  • For this kind of software I would really recommend the brew way of installing it. Not only does that buy you the same effect with less effort, regularly running the update process with brew also keeps you updated to the latest python3 version.
    And IDLE… yes. Well. Not even close enough for no cigar, especially if you realize that there is an excellent IDE called PyCharm for which there is a community version. I would recommend it greatly.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.