Using Python on MacOS

This page is about using Python DIRECTLY on your MacOS system.

If instead, you want information about accessing the ECI/CSIL systems at UCSB using your MacOS system, see this page: CSIL via MacOS

Short version:

Checking if Python is installed already

As a reminder, there are two major versions of Python: Python 2, and Python 3. (Read more about Python 2 vs. 3 here. Your Mac may come with Python 2 installed—if so, you should install Python 3 to work on the assignments in this course, and to match the material in the textbook.

To determine what version of Python is the default on your system, open a Terminal window (see how here) and type ‘python`’

It may look something like this. You can see from the output below that on my machine, I have Python 2.7.11 currently installed as the default for the python command.

Phills-MacBook-Pro:~ pconrad$ python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 12:54:16) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

(To exit, type quit() followed by “enter/return” or hold down “control” while typing D (CTRL-D).)

I might also have Python 3 installed in parallel with Python 2. In that case, typing python3 will bring up Python 3 as shown here:

Phills-MacBook-Pro:~ pconrad$ python3
Python 3.6.0 (default, Dec 24 2016, 08:01:42) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

(Again, type quit() followed by “enter/return” or hold down “control” while typing D (CTRL-D).)

You should also have commands idle and pip available. The Python3 versions may be idle3 and pip3.

If you don’t, see installation instructions below.

Installing Python for MacOS

If you don’t have Python 3.6.2 or higher on your Mac, download and install the latest version of Python for MacOS from here:

Once you’ve installed it, you should have either python, idle and pip commands that work for Python 3.6.2 (or else python3, idle3 and pip3 commands.)