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.
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.
Open an internet browser and visit the official website for Python at Python.org. 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.
After the download completes, open the
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.
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.
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.
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.