Python Installation on macOS
Table of Contents
Objective
This lab will guide you through the process of downloading and installing the latest supported version of Python 3 on your macOS computer. This includes running the official installer, installing necessary SSL certificates, and verifying the installation.
Key Outcomes
- Successfully download the official Python installer for macOS.
- Navigate the Python installation wizard.
- Install Python 3 on your system.
- Install the required SSL root certificates for Python.
- Verify that Python 3 is correctly installed and accessible from the terminal.
Prerequisites
- A macOS computer (macOS 10.13 or later for recent Python versions).
- An internet connection to download the Python installer.
- Administrator privileges on your Mac to install software.
Installation Procedure
-
Step 1: Download Python for macOS
Open your web browser and navigate to the official Python downloads page: https://www.python.org/downloads/
Click on the button to "Download Python X.Y.Z" (where X.Y.Z is the latest version shown for macOS). The downloaded file will be a
.pkg
installer file. -
Step 2: Run the Installer - Welcome
Locate the downloaded
.pkg
file (usually in your Downloads folder) and double-click it to start the installation process.The "Welcome to the Python Installer" screen will appear. Click "Continue".
-
Step 3: Installer - Important Information (Read Me)
The installer will display "Important Information" which includes details about the package, certificate verification, and OpenSSL. After reviewing, click "Continue".
-
Step 4: Installer - Software License Agreement
Next, the "Software License Agreement" will be shown. Review the terms.
Click "Continue". A dialog will pop up asking you to agree to the terms. Click "Agree" to proceed.
-
Step 5: Installer - Installation Type
The "Installation Type" screen will appear. For most users, the standard installation is appropriate. It will show the space required on your computer.
Click "Install" to proceed with the standard installation.
-
Step 6: Installer - Authentication
macOS will ask for your administrator password to allow the installation. Enter your Mac's user password and click "Install Software".
-
Step 7: Installer - Installation Progress
The installer will now copy files and run package scripts. Wait for this process to complete.
-
Step 8: Installer - Summary
Once the installation is finished, the "Summary" screen will appear, confirming that Python was successfully installed. It will also mention the need to install SSL root certificates.
You may be asked if you want to move the Python installer to the Trash. You can choose "Move to Trash" as it's no longer needed.
-
Step 9: Install SSL Certificates
After Python installation, a Finder window for
/Applications/Python X.YZ/
(e.g., Python 3.13) should open. If not, navigate to this folder manually.Double-click on the "Install Certificates.command" file. This will open a Terminal window and run a script to install or update SSL root certificates (using the
certifi
package).Wait for the script to complete. You should see messages indicating that
certifi
was collected and installed, and possibly a notice about pip being upgradable. Once it says something like "saving session...completed." or shows the command prompt again without errors, the certificates are installed. You can then close this Terminal window and the Python installer's summary window. -
Step 10: Verify Python Installation
Open a new Terminal window (Applications > Utilities > Terminal, or search via Spotlight).
Type the following command and press Enter:
python3 --version
You should see the installed Python version printed, for example:
Python 3.13.3
.Alternatively, you can type:
python3
This should start the Python interactive interpreter, showing the version and a
>>>
prompt.To exit the Python interpreter, type
exit()
orquit()
and press Enter, or pressCtrl-D
.Note: On macOS, the command
python
(without the 3) might point to an older, system-provided version of Python 2, or it might not be found. It's best practice to always usepython3
to ensure you are using the version you installed.
Troubleshooting Tips
- Command Not Found (
python3
): Ifpython3
is not found after installation, try closing and reopening your Terminal window. The installer should update your shell's PATH, but sometimes a new session is needed. If it persists, your shell profile (.zshrc
,.bash_profile
, etc.) might need manual adjustment, though this is rare with the official installer. The installer also provides an "Update Shell Profile.command" in the Python application folder that might help. - SSL/Certificate Errors in Python Scripts: If you skip Step 9 (Install SSL Certificates), Python scripts that make HTTPS requests (e.g., using
requests
orpip
to download packages) might fail with SSL certificate verification errors. Re-run the "Install Certificates.command". - Permissions Issues during Installation: Ensure you are running the installer as a user with administrator privileges, and provide the correct password when prompted.
Conclusion
You have now successfully installed Python 3 on your macOS system, including the necessary SSL certificates. Your Mac is ready for Python development and running Python scripts for network automation and other tasks!