Last modified: Feb 12, 2026 By Alexander Williams

Install Python on Mac OS X: A Complete Guide

You want to start coding in Python on your Mac. This guide will show you how. We cover the best methods for a clean Python installation. You will be ready to write your first script in minutes.

macOS comes with an old version of Python. It is used by the system. You should not modify it. Installing a separate, up-to-date version is the correct approach. This keeps your system stable and your tools modern.

Check Your Current Python Version

First, see what's already on your Mac. Open the Terminal application. You can find it in Applications > Utilities.

Type the following command and press Enter.


python3 --version

You might see a version number like "Python 3.9.6". If you see an error, Python 3 is not installed. That's okay. We will install it now.

You may also see a command called python. This often points to Python 2. Python 2 is outdated. You should use Python 3 for all new projects. Our guide focuses on Python 3.

Method 1: Install Python Using Homebrew

Homebrew is a package manager for macOS. It makes installing software easy. It is the preferred method for many developers.

First, install Homebrew if you don't have it. Paste this command in your Terminal.


/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Follow the on-screen prompts. It will ask for your password. Once done, install Python with this simple command.


brew install python

This command installs the latest stable Python 3 and a tool called pip3. Pip is the Python package installer. You will use it to add libraries to your projects.

Homebrew manages updates seamlessly. To update Python later, just run brew upgrade python.

Method 2: Use the Official Python Installer

You can also download Python directly from python.org. This is a straightforward graphical installer.

Visit the official Python downloads page. Download the latest macOS installer. It will be a .pkg file.

Double-click the downloaded file. Follow the installation wizard. A crucial step is to check the box that says "Add Python to PATH". This allows you to run Python from the Terminal.

After installation, open a new Terminal window. Verify it worked with python3 --version.

Method 3: Using pyenv for Version Management

Do you need multiple Python versions? pyenv is the perfect tool for this. It lets you switch between versions easily. This is useful for working on different projects.

Install pyenv using Homebrew.


brew install pyenv

Then, add these lines to your shell configuration file (~/.zshrc for newer Macs).


export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"

Restart your Terminal. Now you can install any Python version. For example, to install Python 3.11.0:


pyenv install 3.11.0
pyenv global 3.11.0

The pyenv global command sets the default version system-wide.

Verify Your Python Installation

Let's make sure everything works. Create a simple test script. Open a text editor and save a file called test.py.

Add the following code to the file. This script prints a message and does a small calculation.

 
# This is a simple test script for Python
print("Hello from Python on macOS!")

# Let's do a quick calculation
result = 7 * 8
print(f"7 multiplied by 8 is {result}.")

# Check the Python version
import sys
print(f"You are using Python version {sys.version_info.major}.{sys.version_info.minor}")

Save the file. Navigate to its location in the Terminal. Run the script with this command.


python3 test.py

You should see output similar to this.


Hello from Python on macOS!
7 multiplied by 8 is 56.
You are using Python version 3.11

If you see this, congratulations! Python is installed and running correctly.

Setting Up a Virtual Environment

You should use virtual environments for your projects. They keep dependencies separate. This prevents conflicts between projects.

Create a new directory for a project. Navigate into it in the Terminal. Create a virtual environment named 'venv'.


python3 -m venv venv

Activate the virtual environment.


source venv/bin/activate

Your terminal prompt will change. It will show (venv) at the beginning. Now, any Python packages you install with pip install will stay inside this environment.

To deactivate the environment, simply type deactivate.

Common Issues and Solutions

Sometimes things don't go as planned. Here are quick fixes for common problems.

"Command not found: python3" after installation. This usually means the PATH is not set. For Homebrew, run brew doctor. For the official installer, re-run it and ensure "Add to PATH" is checked.

Permission errors when installing packages. Never use sudo with pip install. This can break your system Python. Always use a virtual environment instead.

Your IDE or editor doesn't see the new Python. You may need to restart the application. Sometimes you must manually set the Python interpreter path in the IDE's settings.

Next Steps After Installation

You have Python. What's next? Start learning the basics. Explore online tutorials and courses. Practice by building small projects.

Install useful packages. For data science, try pip install pandas numpy. For web development, try pip install flask or django. Remember to do this inside an active virtual environment.

Consider using an Integrated Development Environment (IDE). PyCharm or Visual Studio Code are excellent choices for macOS. They make writing and debugging code much easier.

Conclusion

Installing Python on macOS is simple. The best method is using Homebrew. It provides a clean, manageable installation. The official installer is a good backup. Use pyenv if you need multiple versions.

Always verify your install with a test script. Get into the habit of using virtual environments immediately. This sets a strong foundation for all your future Python work on your Mac.

You are now ready to start your Python programming journey. Your macOS system is equipped with a powerful, modern Python setup. Happy coding!