WittCode💻

How to Install Python on Mac

By

Learn how to install Python and PIP on Mac using the official Python installer.

Table of Contents 📖

Installing Python

The most common way to install Python is using the installer package from the official Python website. This can be found at the following URL:

https://www.python.org/downloads/

Once there, click the download button. It will say something similar to "Download Python 3.12.5". Of course, the version will be different depending on the latest release. After clicking the button, check your downloads for the presence of a pkg file.

INFO: Clicking the button will download a file with a name similar to python-3.12.5-macos11.pkg.

Double click on the file and it will walk you through the installation process. After completing the installation, a folder with the following contents will be created in the Applications folder:

[object Object]

Verifying Installation

To verify installation, double click on the IDLE application inside the newly created folder. This application is an integrated development and learning environment (IDLE) for Python. It is used to write, test, and debug Python code.

Python 3.12.5 (v3.12.5:ff3bc82f7c9, Aug  7 2024, 05:32:06) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
print("hi how are you?");
hi how are you?

The Python installer also added Python to the PATH environment variable so that it can be ran from anywhere. To check, open up a terminal and run the following:

python3 --version
Python 3.12.5

Finally, lets create a simple Python file and run it with Python.

echo 'print("Hello world!")' > /Users/<YOUR_USER>/Documents/PythonScripts/my-py-script.py
python3 /Users/<YOUR_USER>/Documents/PythonScripts/my-py-script.py
Hello world!

Python Package Manager

Installing Python this way also comes with the Python Package Manager called PIP.

pip3 --version
pip 24.2 from /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pip (python 3.12)

This tool allows us to install Python packages that other developers have written.