Author Bob Savage <bobsavage@mac.com> 

## USING PYTHON ON A MACINTOSH 

Python on a Macintosh running Mac OS X is in principle very similar to Python on any other Unix platform, but there are a number of additional features such as the IDE and the Package Manager that are worth pointing out. 

## 4.1 Getting and Installing MacPython 

Mac OS X 10.8 comes with Python 2.7 pre-installed by Apple. If you wish, you are invited to install the most recent version of Python 3 from the Python website (https://www.python.org). A current “universal binary” build of Python, which runs natively on the Mac’s new Intel and legacy PPC CPU’s, is available there. 

What you get after installing is a number of things: 

• A Python 3.9 folder in your $_{Applications}$folder. In here you find IDLE, the development envi- ronment that is a standard part of official Python distributions; and PythonLauncher, which handles double- clicking Python scripts from the Finder. 

• A framework$_{/Library/Frameworks/Python.framework}$ , which includes the Python executable and libraries. The installer adds this location to your shell path. To uninstall MacPython, you can simply remove these three things. A symlink to the Python executable is placed in /usr/local/bin/. 

The Apple-provided build of Python is installed in$_{/System/Library/Frameworks/Python.framework}$ and$_{/usr/bin/python}$ , respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do. 

IDLE includes a help menu that allows you to access Python documentation. If you are completely new to Python you should start reading the tutorial introduction in that document. 

If you are familiar with Python on other Unix platforms you should read the section on running Python scripts from the Unix shell. 

## 4.1.1 How to run a Python script 

Your best way to get started with Python on Mac OS X is through the IDLE integrated development environment, see section The IDE and use the Help menu when the IDE is running. 

If you want to run Python scripts from the Terminal window command line or from the Finder you first need an editor to create your script. Mac OS X comes with a number of standard Unix command line editors, vim and $_{emacs}$among them. If you want a more Mac-like editor, BBEdit or $_{TextWrangler}$from Bare Bones Software (see http://www.barebones.com/products/bbedit/index.html) are good choices, as is TextMate (see https://macromates.com/). Other editors include Gvim (http://macvim-dev.github.io/macvim/) and Aquamacs (http://aquamacs.org/). 

To run your script from the Terminal window you must make sure that$_{/usr/local/bin}$ is in your shell search path. 

