Installing Python 3.12+ on macOS, Windows, and Linux

Installing Python means putting the Python interpreter on your computer so you can run Python programs from the terminal or command prompt. On modern systems, you should install Python 3.12 or newer and then confirm that python3 or the Windows launcher works before you start coding. The rest of this article shows how to install it, check that it is available, fix the most common path problems, and keep multiple versions organized.

Difficulty: Beginner

Helpful to know first: You should know how to open a terminal or command prompt and how to run a command from it.

Installing Python on Your Computer the Right Way

Python is not usually something you write yourself. You install it once so your computer can understand Python code, run scripts, and manage packages later with tools like pip. For a beginner, the main goal is simple: after installation, a command such as python3 --version should print a Python 3.12+ version number.

Most beginners also need to know one important detail: many operating systems already include a Python command for system tools. That built-in version may be old or reserved for the operating system, so do not replace it blindly. Install a current Python version alongside it, then use the new command or launcher that points to the version you installed.

On this site, examples use Python 3.12+ and the standard library only. The installation itself does not depend on third-party packages.

Installing Python on macOS

On macOS, the most reliable choice is the official installer from python.org. It gives you a current Python version, installs the command-line tools needed to run it, and sets up the python3 command for your user account.

Download and install the official package

  1. Open the Python downloads page in your browser.
  2. Download the macOS installer for Python 3.12 or newer.
  3. Open the downloaded package file.
  4. Follow the installer prompts.
  5. Finish the installation and close the installer.

After installation, open Terminal and check the version. This command should print a Python 3.12+ version string.

Terminal
python3 --version # Output: Python 3.12.x

If that command prints a version number starting with 3.12 or newer, the interpreter is ready.

What to use on Apple Silicon and Intel Macs

The installer works on both Apple Silicon and Intel Macs. The important difference is not the chip type but which shell command resolves first in your PATH. If python3 points to the version you installed, you are ready. If it still points somewhere else, the installer may have added a Python framework path that is lower priority than another installation.

When that happens, do not guess. Check exactly where the command comes from:

Terminal
which python3 # Output: /Library/Frameworks/Python.framework/Versions/3.12/bin/python3

If you see a different path, your shell is using another Python first. Adjust your PATH or call the installed interpreter by its full path when needed.

Installing Python on Windows

On Windows, install Python from the official python.org installer and make sure the launcher and PATH options are set correctly. The Windows installer can add the py launcher, register file associations, and optionally add Python to your PATH so the command prompt can find it.

Use the installer and choose the right options

  1. Download the Windows installer for Python 3.12 or newer.
  2. Run the installer.
  3. Check Add python.exe to PATH if you want python to work in Command Prompt and PowerShell.
  4. Choose Install Now or customize the location if you need a different folder.
  5. Finish the installation.

Then open Command Prompt and check the version.

Terminal
python --version # Output: Python 3.12.x

On many Windows systems, the more reliable check is the launcher:

Terminal
py -3 --version # Output: Python 3.12.x

The launcher is useful because it can find installed Python versions even when python is not on PATH.

How Windows handles the python command

Windows can show a Microsoft Store alias or another stub if Python is missing or if an app execution alias is enabled. That can confuse beginners because python may not start the interpreter you just installed. If that happens, use py first, then fix PATH or disable the store alias if needed.

Installing Python on Linux

On Linux, Python is often already installed for system tools, but the version may be older than you want. If your distribution package manager offers Python 3.12 or newer, install that package. If it does not, use your distribution’s recommended method or build from source only if you know you need to.

Install with your package manager when the version is recent enough

On Debian-based systems, the package name and version vary by release. On modern releases, you can install Python and the development tools with your package manager. One common pattern is:

Terminal
sudo apt update
sudo apt install python3 python3-venv python3-pip

After installation, verify the version:

Terminal
python3 --version # Output: Python 3.12.x or newer

If your distribution only offers an older version, do not overwrite the system Python. Use your distribution’s packaging guidance or a user-local install method instead of replacing the operating system interpreter.

Why Linux often uses python3 instead of python

Many Linux systems keep python unassigned or reserved, while python3 is the standard command for Python 3. That separation helps avoid breaking scripts that still expect an older interpreter. If your terminal says python: command not found, that is not necessarily a problem. On Linux, python3 is usually the command you should use.

Checking That Python Works After Installation

The first check should confirm the interpreter version. The second check should prove that you can run a tiny program. If both work, the installation is usable.

Check the version

Run the version command that matches your platform:

Terminal
python3 --version # Output: Python 3.12.x

or, on Windows:

Terminal
py -3 --version # Output: Python 3.12.x

Run a one-line program

This command starts Python, runs a small program, and exits. It proves that the interpreter can execute code, not just report its version.

Terminal
python3 -c "print('Hello, Python!')" # Output: Hello, Python!

If you are on Windows and python3 does not work, use py -3 instead.

The First Configuration That Matters

After installation, the most important setup step is usually PATH. PATH tells your shell where to look for commands. If the wrong Python appears first, your computer may use an older version or an alias you did not expect.

Know which command your system should use

PlatformCommon commandWhy
macOSpython3The official installer registers Python 3 separately from any older system command.
Windowspy -3 or pythonThe launcher can find installed versions even when PATH is imperfect.
Linuxpython3Distributions commonly keep python separate from Python 3.

If you want to make a project use a specific Python version later, you usually do that with a virtual environment. That is a separate topic, but it begins with a correct installation.

Problems You May Hit During Installation

Most installation problems come from version confusion, PATH problems, or using the wrong command for the operating system. The fixes are usually simple once you know what is happening.

python says command not found

This usually means your shell cannot find a python command on PATH. That is common on macOS and Linux, where the correct command may be python3 instead.

Problem: You installed Python, but the shell still cannot find the command name you typed.

Terminal
python --version
# bash: python: command not found

Fix: Try python3 --version. If that works, use python3 for this installation. If neither command works, reinstall Python or add the install directory to PATH.

Terminal
python3 --version

The corrected command works because many systems expose Python 3 as python3 rather than python.

Windows opens the Microsoft Store instead of Python

Some Windows setups keep an app execution alias for python. If that alias is active, typing python can open the Store prompt instead of your installed interpreter.

Problem: The operating system is intercepting the command before it reaches the interpreter you installed.

Python
python

Fix: Use py -3 to run Python 3, or disable the Store alias in Windows settings and make sure the installer added Python to PATH.

Terminal
py -3

The launcher works because it points directly to installed Python versions instead of relying only on the command name.

An older version appears after you install a newer one

This happens when another Python installation appears earlier in PATH. The shell uses the first matching command it finds, so a system Python, Homebrew Python, or another older install can win.

Problem: The version you see is not the version you just installed, so your terminal is finding a different interpreter first.

Terminal
python3 --version
# Python 3.11.x

Fix: Check the command location with which python3 on macOS and Linux, or where python on Windows. Then adjust PATH or use the launcher or full path to the intended interpreter.

Terminal
which python3

That check shows which executable your shell is actually using, which is the fastest way to find the conflict.

Updating Python and Managing More Than One Version

Python versions change over time, so you will eventually update. The safest approach is to install a newer Python alongside the older one, verify it, and then choose the version you want for each shell or project. Avoid removing the system Python on Linux or macOS unless the operating system vendor explicitly says it is safe.

On Windows, the py launcher can help you switch versions without changing your PATH every time. On macOS and Linux, a shell alias or full path can also point to a specific interpreter, but the best long-term practice for projects is to use virtual environments so one project does not depend on another project’s Python.

Installing Python is the first step. The next important step for real projects is creating a virtual environment so each project can use its own packages and interpreter settings.

Predict the Output

These short examples test two beginner misunderstandings: whether python and python3 mean the same thing, and whether the installed command always comes from the location you expect.

Snippet 1

Python
print(3 / 2)
print(3 // 2)

What does this print?

Show answer

The first line prints 1.5 because / does true division and returns a float. The second line prints 1 because // does floor division and drops the fractional part for positive numbers.

Python
1.5
1

Snippet 2

Python
x = [1, 2]
y = x
y.append(3)
print(x)

What does this print?

Show answer

Both names point to the same list object, so changing y also changes x. The output is the list with the added value.

Python
[1, 2, 3]

Find the Bug

Find the mistake in this installation check script. It looks reasonable, but it gives a confusing result if the wrong command is available first.

Python
import subprocess

result = subprocess.run(
    ["python", "--version"],
    capture_output=True,
    text=True,
)
print(result.stdout or result.stderr)
Show answer

The bug is that the script assumes python is the right command on every system. On many macOS and Linux systems, the correct command is python3, and on Windows the launcher py -3 is often more reliable.

Fixed version:

Python
import subprocess

result = subprocess.run(
    ["python3", "--version"],
    capture_output=True,
    text=True,
)
print(result.stdout or result.stderr)

The corrected version works because it uses the command name that most Unix-like systems expose for Python 3.

When to Use the Installer, the Launcher, or a Package Manager

Different systems give you different tools for the same goal. The best choice depends on whether you want a current official Python, a distribution-managed Python, or a way to switch between versions.

ChoiceUse it whenAvoid it when
Official installerYou want the simplest, most direct install from python.org.You are relying on your Linux distribution’s package policy.
Windows launcher pyYou want to select installed Python versions on Windows.You are trying to replace PATH setup entirely.
System package managerYou want Python managed with the rest of your OS packages.The available version is too old for your needs.

If you are a beginner, the official installer is usually the easiest place to start on macOS and Windows. On Linux, use the package manager if it provides the version you need and fits your distribution’s recommended workflow.

Interview question: Why is python3 safer than python on many systems?

Because it avoids confusing the current Python 3 interpreter with older or system-reserved commands. It also reduces the chance that a script or terminal session will pick up the wrong executable from PATH.

Interview question: Why should you not replace the system Python on Linux?

Because operating system tools may depend on it. Replacing it can break package managers, desktop tools, or update scripts. Install a separate version instead.

Interview question: What is the difference between python --version and python -c?

--version only reports the interpreter version. -c runs a short Python program. The second check is better when you want to confirm that the interpreter can actually execute code.

Try It Yourself

  • Open your terminal or command prompt.
  • Check which Python command works on your system.
  • Print the Python version.
  • Run a one-line Python program that prints your name and your version check result.

Expected output: Your terminal should show a Python 3.12+ version number and then a short greeting message from your program.

Hint: Use python3 on macOS and Linux, or py -3 on Windows if python does not work.

Show solution
Python
import sys

print(sys.version)
print("Hello, my Python installation works.")

Summary

  • Install Python 3.12 or newer so you have a current interpreter.
  • On macOS and Linux, python3 is usually the command you should use.
  • On Windows, the py -3 launcher is often the most reliable way to start Python.
  • Verify the install with --version and a tiny program, not just by trusting the installer.
  • If a different version appears, check PATH and which executable your shell is finding first.
  • Do not replace the system Python on Linux; install a separate version instead.

Next, learn how to create a virtual environment so each Python project can use its own packages and interpreter settings without interfering with other projects.