Skip to content

Install and Setup For Mac

Python typically comes preinstalled on Mac OS. You can verify Python has been installed in the Terminal. Enter the command below to verify if Python is already installed on your machine. The output of this command will display the version of Python that is currently installed.

python --version
Python 2.X.X

To ensure that you are able to follow along with the rest of this book you will want to make sure you have the latest version of Python 3 installed.

Download Python

Open an internet browser and visit the official website for Python at Click on the Downloads tab and the site should automatically detect the operating system you are using and offer up the latest version of Python 3 for your machine.

Install Python

After the download completes, open the .pkg file and start the installation. If you have installed software before you will notice that the installation walkthrough looks familiar. You can accept the default install configurations and choose whether to agree to the terms of use.

Note: You may need to input your password to finalize the installation.

Once the installation is finished a Python 3.X directory will be placed in your Applications folder. Inside this Python 3.X folder you will see an application labeled as

Check Installed Version

Back in the Terminal, execute the same command you entered to verify if Python was installed. You will most likely see the same Python version shown previously. This is because Python 3 uses a different command, python3 instead of python. Try executing the command below in the Terminal to check the Python 3 version.

python3 --version
Python 3.X.X

Creating an Alias

You can create an alias for the python3 command that allows you to instead use python in the Terminal. To create an alias open the bash_profile file using the command below.

nano ~/.bash_profile

At the bottom of the file you should see a few lines that were added from the Python 3 installation. Below these lines at the bottom, and on a new line, add the following alias.

alias python=python3

To save this hit CTRL+X to close the file, hit Y to save the changes, and then hit Enter to keep that same file name.

Now let's check the Python version again. This time you should see that you are using Python 3.

python --version
Python 3.X.X