The fastest way to check Python on your Mac

Open Terminal (find it in Applications > Utilities or press Command + Space and type "Terminal"), then type one of these commands and press Enter:

For Python 3: python3 --version

For Python 2: python --version

The output will show you the exact version number — for example, "Python 3.11.7" or "Python 2.7.18". Most Macs come with Python 2 pre-installed, but Python 2 stopped receiving updates in 2020, so you likely need Python 3 for current work.

If you get a "command not found" error, Python is not installed on your system, or the command name is different than expected. This is common on newer Macs, where you may need to install Python separately through Homebrew or the official Python installer.

Key Takeaways

  • Type python3 --version in Terminal to see which Python 3 release you have installed.
  • Macs often come with Python 2 pre-installed, but Python 2 is no longer maintained and most projects require Python 3.
  • If the command returns "not found", you need to install Python using Homebrew or download it from python.org.
  • You can have both Python 2 and Python 3 on the same Mac; the commands python and python3 point to different versions.

Why you might have multiple Python versions

Many Macs ship with Python 2 already installed because older system tools and scripts relied on it. However, Python 2 reached end-of-life in January 2020, meaning it no longer receives security patches or bug fixes. Almost all new projects, libraries, and frameworks now require Python 3.

You can have both versions on your Mac at the same time without conflict. The command python typically points to Python 2, while python3 points to Python 3. When you install a package or run a script, you choose which version to use by picking the right command.

If you are starting a new project or learning Python, use Python 3. If you are maintaining older code, you may need to keep Python 2 around, but you should plan to migrate it eventually.

Installing Python 3 if it is not on your Mac

The most straightforward way is to use Homebrew, a package manager for Mac. If you do not have Homebrew installed, open Terminal and run:

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

Once Homebrew is ready, install Python 3 by typing:

brew install python3

Homebrew will download and set up Python 3 automatically. When it finishes, run python3 --version again to confirm the installation worked.

Alternatively, you can download Python directly from python.org. Go to the Downloads section, choose the macOS installer for the version you want, and follow the on-screen steps. This method is simpler if you prefer not to use Homebrew, but Homebrew makes it easier to update Python later.

Checking which Python your scripts are using

When you run a Python script, you need to tell your Mac which version to use. If you type python script.py, it runs with Python 2 (if installed). If you type python3 script.py, it runs with Python 3.

You can also check which Python a script is set to use by looking at its first line. Open the script in a text editor and look for a line like #!/usr/bin/python or #!/usr/bin/python3. This line, called a shebang, tells your Mac which interpreter to use when you run the script directly (without typing python in front of it).

If you are unsure which version a project needs, check its README file or documentation. Most modern projects specify Python 3.8 or later. If the project is old or unmaintained, it might still target Python 2, but you should avoid starting new work with Python 2.

Finding the full path to Python on your Mac

Sometimes you need to know exactly where Python is installed on your system. In Terminal, type:

which python3

This returns the full path, usually something like /usr/local/bin/python3 or /opt/homebrew/bin/python3. The path depends on how you installed Python — Homebrew puts it in a different location than the official installer.

You may need this path if you are setting up a development environment, configuring an editor, or troubleshooting why the wrong version of Python is running. Some tools ask for the full path instead of just the command name.

Checking Python version inside a script

If you are writing Python code and need to know the version while the script is running, add this to your script:

import sysprint(sys.version)

This prints the full version information, including the build number and compiler details. You can also use sys.version_info to get individual parts of the version number — useful if your script needs to behave differently depending on whether it is running on Python 3.9 versus 3.11, for example.

Frequently Asked Questions

What if I have Python 3 installed but python3 command does not work?

Your Python installation may not be in your system's PATH, or the command name might be different. Try which python3 to see if it exists. If that returns nothing, Python 3 is not installed or not set up correctly. Reinstall it using Homebrew or the official installer, and make sure the installation completes without errors.

Can I remove Python 2 from my Mac?

The Python 2 that comes pre-installed on older Macs is part of the system and should not be removed — some Mac tools still depend on it. If you installed Python 2 separately using Homebrew, you can remove it with brew uninstall python@2. Removing the built-in version can break system functionality.

Why do I see different versions when I type python and python3?

On most Macs, python points to Python 2 and python3 points to Python 3. They are separate installations. If you only have Python 3 installed, python may not work at all, or it may point to Python 3 depending on how your system is configured. Always use python3 if you want Python 3.

How do I update Python to a newer version?

If you installed Python using Homebrew, run brew upgrade python3. If you used the official installer, download the newer version from python.org and run the installer again — it will update your existing installation. Check the version afterward with python3 --version to confirm the update worked.