Mac Install Python
How to install Python on Mac. Python installation options explained. Python tool complexity with version managers, package managers, and environment managers. How to reduce Python development complexity.
Python is extremely popular, especially for beginners. There are multiple ways to install Python, which can lead to confusion. This guide considers different ways to install Python and recommends the best way, depending on your needs.
Before you get started
You'll need a terminal application to install Python. Apple includes the Mac terminal but I prefer Warp Terminal. Warp is an easy-to-use terminal application, with AI assistance to help you learn and remember terminal commands. Download Warp Terminal now; it's FREE and worth a try.
Shortcuts to install Python
This guide recommends the best way to install Python on Mac, depending on your needs. If you just want to get started quickly, jump to these guides:
- Install Python with Pipx for running Python applications
- Install Python with Rye for writing code
Steps
See my guide to Mac Python to understand what's needed for a Python development environment, including how to use Python version managers and package managers for your Python projects.
Here's how you can install Python on Mac.
- Check macOS and update macOS if necessary.
- Check if Xcode Command Line Tools are installed.
- Install Python with Pipx (for scripts and utilities).
- Install Python with Rye (recommended for programming).
- Set the Mac PATH for Python to make sure you use the correct version of Python.
Common errors
If you are trying to install Python, you may encounter these common errors. See the guides for help:
- zsh: command not found: python if Python is not installed or the [Mac PATH] is not set correctly
- zsh: command not found: pip if you are trying to install a Python program or package
5 ways to install Python
There are multiple ways to install Python on Mac. That's because there are multiple reasons to use Python on a Mac and each type of use may install Python differently, in different places on your computer.
Consider the ways Python is used on a Mac. First, system software or utilities may require Python. This includes the Python version installed with Xcode Command Line Tools or the Homebrew package manager. Second, you may want to run a software program that requires Python, such as a script or utility. Ideally, you'll install Pipx to manage these programs, which automatically installs a suitable Python version. Third, you may be a professional developer who needs to write code using multiple Python versions and packages. In this case, you'll install Python with Rye (recommended) or install Python with Pyenv. Software developers also install Python with Homebrew, the official Python installer, or specialty tools such as Anaconda, Miniconda, Miniforge, or Mambaforge for data science and machine learning. I'll compare these installation options here.
Options Explained
Let's consider why you want to use Python and which installation options are appropriate.
Python for system software
You may already have Python installed as system software. You can check if the Mac system Python is installed.
Prior to macOS 12.3, Macs came with Python 2.7 pre-installed. Don't use any Python 2 version for development and update macOS if it's 12.3 or older.
When you install Xcode Command Line Tools, Apple includes Python 3.9.6. That's an older version. In principle, you can use the system Python installed by Xcode Command Line Tools for running Python applications or programming but as soon as you install Python packages you'll end up with a cluttered system that's hard to maintain, as running pip
to install packages will create a duplicate Python installation in your user folder. Instead, install Pipx to run Python applications on a Mac and for programming in Python, install Python with Rye (recommended) or install Python with Pyenv and set the Mac PATH.
Python and Homebrew
If you are using Homebrew to install software on your Mac, you may have installed Python with Homebrew. Homebrew is a package manager for macOS. Homebrew installs Python automatically for some software packages that require it. You can check if Python is installed with Homebrew by running brew list python
. If you have Python installed with Homebrew, you can use it for running Python scripts. However, Python automatically updates Python which may cause problems for programming projects. If you use Homebrew, you can install Python with Pyenv to add a Python version that is managed separately from Homebrew. You'll need to set the Mac PATH to use the Python version installed with Pyenv. Additionally, you will need to use Venv and Pip to manage Python environments and packages for programming projects, which is why I recommend that you install Python with Rye for an all-in-one tool instead.
Python for running programs
If you want to run Python applications, you should install Pipx. Pipx is a package installer for Python applications. It installs Python applications in isolated environments, so they don't interfere with each other or with system software. It's best to install Pipx to run Python applications on a Mac.
Use Pipx for stand-alone Python programs and utilities. There are a growing number of stand-alone programs that require Python to run, such as Youtube-dl, a command-line utility to download videos from YouTube. In addition to stand-alone Python programs, Python programming tools, such as Ruff, a Python code formatter, should be installed with Pipx. Programming tools must be available to all projects ("globally") but isolated from each other.
If you see pip install <package>
in a README or tutorial, ask yourself if you are installing a software library that will be used in a programming project (in which case, use Rye or Pyenv), or if you are installing a stand-alone program or utility (in which case, use Pipx).
Python for programming
If you are a professional developer who needs to write code using multiple Python versions and packages, you should install Python with Rye. Rye is a Python version manager, package manager, and environment manager. It's a simple tool that makes it easy to manage Python versions and packages. Rye is the best way to install Python on a Mac for development.
Here are other ways to install Python for programming.
- Install Python with Pyenv for managing Python versions. Pyenv is a Python version manager only. You will need to use Venv and Pip to manage Python environments and packages for programming projects to isolate projects and avoid dependency conflicts.
- The official installer package from the Python website adds files to
/usr/local/bin
, modifies your Mac PATH, and installs the latest Python version in the macOS/Library/Frameworks
folder. Though it's the official Python website installer, most Python developers avoid using it because it clutters a Mac in ways that are difficult to manage. - Historically, Anaconda, Miniconda, Miniforge, or Mambaforge have been used to install Python and software packages for data science and machine learning. Tutorials and READMEs may give instructions with these tools. Many developers now prefer to use Python's standard tools such as Pyenv, Venv, and Pip rather than the specialized tools from Anaconda, Miniconda, Miniforge, or Mambaforge.
Summary of how to install Python on a Mac
Installing Python will require these steps:
- Check macOS and update macOS.
- Check if Xcode Command Line Tools are installed.
- Install Python with one of these methods:
- install Pipx to run Python applications;
- install Python with Rye for Python programming;
- or install Python with Pyenv to use standard tools Venv and Pip.
- Don't use the system Python installed by Xcode Command Line Tools or Homebrew for running Python applications or programming.
- Set the Mac PATH for Python to make sure you use the correct version of Python.
What's next
My mac.install.guide is a trusted source of installation guides for professional developers. Take a look at the Mac Install Guide home page for tips and trends and see what to install next.