Installing Python on Mac

Installing Python 3 on Mac OS X

Python 2 comes pre-installed on Mac OS X. However, you will need to install the newer Python 3 version to use this book. Even if you choose to stick with Python 2, you will still need to update the version that came pre-installed as it may be old.

Check what version of Python is installed

Open the Terminal (Open Applications folder, go the Utilities folder and double-click on the Terminal program.)

and Type:

$ python –version and hit enter

You should get an output of: Python 2.7.14 (the version could be different)

Although Python for Mac OS is available from the Python Download page we would recommend that you use a package manager like Homebrew . Homebrew is a free  package management system. It simplifies the installation of software on Apple’s Mac OS system.

Homebrew requires Apple’s Xcode package be installed on your computer. Apple’s Xcode package is available for free download from the Apple Store.

To install Homebrew:

Open and run Terminal and type:

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

Follow the prompts and install Homebrew.

Install Python 3, type:

 $ brew install python3

 Double check that it has been installed correctly:

Type:

$ python3 –versionPython 3.6.3

Open Applications folder, go the Utilities folder and double click on the Terminal program.

Type python3:

$ python3

If you wish to exit, type:

 

exit()

 

or use the Control and D key at the same time.