Python has become one of the most popular programming languages in the world with its incredible versatility. Whether you plan to build a website or an application yourself in Python, or want to run software that requires Python, you may need to install Python on your Mac.
This guide will discuss three of the most popular ways to get Python on your Mac and briefly introduce some alternatives.
Does the Mac system come with Python?
Unfortunately, since macOS Catalina, Mac computers no longer have Python pre-installed, although it is included in older versions of the OS, including Mojave and earlier. If you want to use Python on your Mac today, you need to set it up and manage it yourself.
Even if you are running an OSX version containing Python, it may be an old version now—especially if you are not deliberately manually updating it. Given this, it's better to make sure you're running the latest version before you start using it.
How to check if Python is installed on your Mac
There is an easy way to check if Python is installed on your Mac:
- Start Terminal from the Applications > Utility folder.
- Enter the command
python3
and press Enter.
If you have Python installed on your Mac, you will see the version number. If not, you will receive an error message.
How to install Python on Mac
You can get Python on your Mac in a number of different ways, some of which are simpler than others, and all work on Apple silicon chips (M1, M2, M3, and M4 chips) and Intel machines.
The following are three common methods that do not require much effort:
- Install Python on Mac through the installer
- Install Python on macOS using Rye
- Install Python on MacBook using Homebrew
Choose the right installation method depends on your needs. If you only need Python to run programs and utilities that depend on it, an easy way to use the official Python installer should be great for you. However, if you are developing in Python in multiple environments, the Rye option is ideal.
Before proceeding, if you already have an older version installed, you may need to uninstall Python from your Mac. If you do not set up a virtual environment for each required version, installing a different version can lead to conflicts, which is actually only necessary for more complex Python projects.
1. Install Python on Mac through the installer
Installing Python on your Mac using the official installer is one of the fastest ways to get it up and running, and if you just want to run Python programs and tools, this may be all you need. Just follow the steps below:
- Download the latest version of Python from the official website
- Run the installer
- Verify installation
1.1 Download the latest version of Python from the official website
First of all, you need the official Python installer:
- Download Python 3 from the macOS section on python.org.
- Click on "Latest Python 3 Version" at the top of the page.
- Scroll down to the Files section and select macOS 64-bit Installer.
- When the system prompts you to continue, click "Allow".
1.2 Run the installer
After downloading of the Python installer is completed, you can run it:
- Open your Downloads folder in Finder and double-click the Python package to run it.
- When the "Install Python" window appears, click "Continue" and follow the steps on the screen.
1.3 Verify installation
After the Python installer is finished, a new Python folder will appear, containing the official IDE (integrated development environment) called IDLE, the Python launcher, and some text documents. This means that Python has been installed successfully, but you can verify the installation using the above steps.
2. Install Python on macOS using Rye
If you use Python for programming, you may need more advanced settings, especially if you plan to write more complex projects. A good option is to install Python using Rye, which allows you to install multiple "toolchains" simultaneously, which are essentially different versions of Python.
The following is how to install Python on your Mac using Rye:
- Installation Rye
- Set Rye's PATH
- Verify Rye Installation
- Verify Python installation
2.1 Install Rye
You can quickly download and install Rye using the curl command in the terminal. Please follow the steps below:
- Use the administrator account to open the terminal.
- Enter
curl -sSf https://rye.astral.sh/get | bash
and press Enter. Press the y key to continue when prompted. - The system will ask you which package installer you want to use: uv or pip-tools. While UVs are updated and faster, pip offers better compatibility. It's also more friendly for beginners, as many tutorials mention pip. Use the arrow keys on the keyboard to select pip-tools and press Enter.
- Next, you will be asked which Python setting you want. Select Run Python installed and managed by Rye, and press Enter.
- Then, you need to select a version of Python you want to use as the default toolchain. Typically, it is recommended to use the latest version of Python, so unless you want another version, just press Enter.
2.2 Setting Rye's PATH
Rye After completing the Python installation, you will be asked if you want to add Rye to the PATH via .profile. This is usually best on Linux, but on macOS, it is best to set PATH in .zprofile. So let's set the PATH manually as follows:
- When asked if you want to add Rye to PATH via .profile, type n to reject.
- Now we need to open the
~/.zprofile
file for editing. In the terminal, typeopen -e ~/.zprofile
and press Enter. - By default, the file will be opened in TextEdit, a built-in text editor for Mac. However, if you have changed the text editor to a Notepad alternative to Mac or a similar editor, the .zprofile file will open in it.
- In the last line of your .zprofile configuration file, enter
source "$HOME/.rye/env"
, and save and close the file. You need to close and reopen the terminal to start a new session for the changes to take effect.
When Rye's PATH is set, the Python
or Python3
command will now use the Python version installed by Rye, which is exactly the expected result. To confirm that the PATH is correct, type the echo $PATH
command into the terminal and press Enter. Your directory should have *.rye/shims
at the beginning.
2.3 Verify Rye Installation
After completing the above steps, verify that Rye installation is simple:
- In the terminal, type
rye --version
, and press Enter.
The version number should be displayed. If you see an error, check that you entered the correct command and that you followed the installation steps correctly.
2.4 Verify Python installation
Verify that Python installation is also easy, as shown below:
- In the terminal, type
python --version
and press Enter to display the Python version number.
If you see "zsh: command not found error", check that you have set PATH correctly by repeating the above steps.
3. Install Python on MacBook using Homebrew
If you want to build a simpler project with Python, it's quite easy to install Python using Homebrew, as shown below:
- Preinstalled Python
- Check Homebrew is ready
- Brew Installation
- Verify using brew list
- Brew pin
- Update Python with Homebrew
- Set $PATH of Homebrew Python
- Verify Python installation
3.1 Preinstalled Python
If you are a software developer, you may have installed Xcode on your Mac, including a Python version. It is important that you don't delete it. Instead, we will use Homebrew to install the latest version. However, for security reasons, Anaconda and other third-party tools can be uninstalled from your MacBook.
One of the fastest ways to uninstall older versions of Python and other unwanted applications on your Mac is to use MacKeeper's Smart Uninstaller. It recognizes all software installed on your Mac and allows you to delete multiple programs and their associated files in just a few clicks.
The following is how to use it:
- Select Smart Uninstaller in the MacKeeper sidebar and click "Start Scan".
- After the scan is complete, select all the applications, widgets, plugins, and other items you want to uninstall, and click "Delete Selected Projects" to delete them.
3.2 Check if Homebrew is ready
Before you can install Python with Homebrew, you need to make sure it is ready and updated:
- Open the terminal, type the
brew update
command, and press Enter. - After any updates are finished, verify that Homebrew is ready to install the package by typing
brew doctor
and pressing Enter.
If Homebrew is not installed, you will see the "zsh: command not found" error. To install it, copy and paste /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
into the terminal, press Enter and follow the on-screen steps.
3.3 Brew installation
Homebrew is ready and updated, we can now install Python:
- Type
brew install python
into the terminal and press Enter.
3.4 Verify using brew list
After the installation process is completed, we can verify that Python is installed correctly:
- Type
brew list python
into the terminal and press Enter to view the list of installed files.
3.5 Brew pin
Homebrew will update Python as needed, but you may want to prevent this from happening – especially with some projects relying on a specific version of Python. You can use pin to prevent automatic updates:
- In the terminal, type
brew pin python
, and press Enter. - You will not receive a response from the above command, but you can verify that it is valid by typing
brew info python
. You should seepinned
at the end of your Python version number.
If you want to update or reinstall Python with Homebrew in the future, you can delete the pin by typing the brew unpin python
command.
3.6 Upgrade Python with Homebrew
To upgrade Python with Homebrew, just type brew upgrade python
into the terminal and press Enter. Note that we are using upgrade
instead of update
here, because the update
command is used for Homebrew itself.
Remember that some of your projects and programs may require a specific version of Python to work properly. It is recommended that you check these dependencies before performing an update to avoid breaking anything you need.
3.7 Set $PATH of Homebrew Python
After installing Python with Homebrew, you need to manually set $PATH, which is normal in most installation methods. Here's how to do this:
- In the terminal, enter
open -e ~/.zprofile
to open the configuration file in TextEdit. - On the last line of the file, enter
export PATH="$(brew --prefix python)/libexec/bin:$PATH"
, and save and close it. Your Homebrew version of Python will now take precedence over any other Python installation, but remember to close and restart the terminal for the changes to take effect.
3.8 Verify Python installation
To verify that Python is installed correctly using Homebrew, type which python
into the terminal and press Enter. You should see the Python version number and the PATH you set above.
Other ways to install Python on Mac
Depending on how you want to use Python, other installation methods may be more appropriate. The methods we've covered in detail above are some of the most common methods that should suit most use cases, but if they don't meet your needs, you may want to consider installing Python with pyenv or Conda.
The best way to install Python on Mac
One of the big advantages of Python is that it is very flexible. No matter how you want to use it, you will find a setup method that perfectly matches your needs. For most Mac users, we recommend two options: the official Python installer for running Python applications, and for development using Rye.
If you need to remove Python programs and other unwanted software, check out MacKeeper's Smart Uninstaller. It can clear all unwanted applications and delete all associated files at once, while other uninstall methods usually leave these files behind.
The above is the detailed content of Install Python on Mac: What Is the Best Way to Do This on MacOS?. For more information, please follow other related articles on the PHP Chinese website!

Mac Dockbar Optimization Guide: Show only running applications The dock bar of your Mac is the core of the system, from which you can launch Finder, Trash, recently used apps, active apps, and bookmark apps, and even add folders such as Document and Downloads. By default, the Mac dock bar will display more than a dozen Apple-owned applications. Most users will add more applications, but rarely delete any applications, resulting in the dock bar being cluttered and difficult to use effectively. This article will introduce several ways to help you organize and clean up your Mac dock bar in just a few minutes. Method 1: Manually organize the dock bar You can manually remove unused applications and keep only commonly used applications. Remove the application: Right-click on the application

Protecting your online privacy is crucial in today's digital world. This guide details how to delete your browsing history on a Mac, enhance your online security, and block unwanted ads and trackers. We'll cover manual methods and efficient automat

When working in a dark environment, reversing the color of the Mac screen can effectively relieve eye fatigue and also help people with visual impairment improve their user experience. This feature can also improve contrast or help people with color vision defects distinguish colors. You can easily switch between the inverted color and the original color of your Mac screen, as follows: How to reverse display color on Mac You can reverse the color of your Mac screen through System Preferences. Click on the Mac menu, and then select System Preferences > Accessibility > Display, and check the "Invert Color" option: Depending on your screen needs, you may just need to use dark mode. To enable dark mode on your Mac, turn on System Preferences&g

Even though function keys on Mac, or F keys, have been a staple of Apple keyboards forever, it seems like fewer people are using them these days, or even know what they are for. It’s time to fix that! Mac function keys are not the most versatile

iPad Printing Guide: Easily Print Your Files and Photos With the iPad equipped with M1 chip, 5G network, improved ports and powerful productivity functions, more and more people choose to replace Macs with iPads to reduce the burden on backpacks. Alternatively, you might use your iPad as an extension to your workspace. Either way, you may need to learn how to print from your iPad. There are two main methods. The easiest way is to use Apple's native printing technology, AirPrint printer. But if your printer doesn't support AirPrint, don't worry, we'll explain how to print from your iPad without AirPrint. We will also answer questions like "What is AirPrint hitting"

Transferring photos from your iPhone to your Mac is a breeze, whether you're sharing instantly or creating a backup. This guide explores several methods, catering to different needs and preferences. Managing your iPhone's storage, ensuring photo saf

This guide provides a quick and easy method for converting iMovie videos to MP4 format on a Mac. We'll cover exporting directly from iMovie, using alternative apps, and troubleshooting common issues. Here's a comparison of different methods: App

M1 Mac Data Protection Guide: Responding to SSD Failures and External SSD Issues Storage device failure is a frustrating nightmare, and precious Mac data can disappear in an instant! Especially for Macs equipped with M1 chips, internal SSD failures will lead to the inability to start the system, and the risks cannot be ignored. This article will guide you in backing up and restoring valuable data and resolving external SSD issues. Reasons why the M1 Mac cannot boot from an external drive Macs equipped with Apple silicon chips cannot start macOS in case of internal SSD failure. This is due to a new security policy that revolutionizes the startup and recovery process for the M1 Mac, based on the so-called “1 Tr


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment