Installing Python 3.12 takes about five minutes on any major operating system, and almost every beginner who believes they have a broken install is actually looking at a PATH problem or a stray Microsoft Store alias. This guide walks through the Windows, macOS and Linux routes, shows the exact commands that verify a working install, and gives you a diagnostic script so you can prove which Python your terminal is really running.
Which Python should you install?
Install a current 3.x release. This course is written against Python 3.12 and runs unchanged on 3.13 and 3.14, so any of those three is a fine choice. What you should not do is install Python 2, which reached the end of its life in 2020 and is still offered by some older tutorials; code written for it behaves differently in ways that will waste your afternoon.
Two secondary decisions are worth making up front. First, install the interpreter itself and keep third-party packages inside a virtual environment, which you will learn about later in the course. Second, if your operating system ships a system Python, install your own alongside it rather than trying to replace it; system packages sometimes depend on the version the distro shipped, and breaking it can stop unrelated tools from running.
How do I install Python on Windows?
The official installer from python.org is the most predictable route. Download the 3.12 Windows installer, run it, and pay attention to the very first screen: tick the box that says "Add python.exe to PATH". That single checkbox is the difference between a terminal that can run python and one that says "command not found".
If you prefer a package manager, the Windows Package Manager has the official builds:
winget install Python.Python.3.12installs the same interpreter and adds it to PATH for you.choco install python312does the same thing under Chocolatey.
Two Windows-specific traps are worth naming now. The first is the Microsoft Store version. If you install Python from the Store, Windows registers a app execution alias called python.exe. Typing python in a terminal then opens the Microsoft Store instead of running your interpreter, and the terminal appears to hang. The fix is to uninstall the Store package, install from python.org, and re-check that the box at the bottom of the installer is ticked.
The second trap is having two interpreters at once. If you install 3.12 and 3.13 side by side, python follows whichever was registered last. The Python Launcher handles this cleanly: py -3.12 --version runs a specific version regardless of PATH, and py -0 lists everything the launcher can see. Installers on Windows offer the launcher by default; accept it.
How do I install Python on macOS?
macOS makes this easy in two different ways, and only one of them gives you the version you asked for.
The python.org installer is the most predictable: download the 3.12 macOS universal binary, open it, drag Python into your Applications folder, and close it. It installs a command line tool under /Library/Frameworks/Python.framework/Versions/3.12/bin, and the installer offers to add it to your shell path. On recent macOS versions, that path is set up automatically by the installer.
Homebrew is the route most developers take on macOS. brew install [email protected] installs the interpreter, and because versioned formulae are keg-only, you usually need to add the directory to your path yourself or link it with brew link --force [email protected].
Here is the trap that catches nearly everyone: macOS ships a python3 command of its own, installed by the Xcode command line tools, and it is usually an old release. Typing python3 --version on a fresh Mac may report a version several years old, and python without the "3" usually means "not found" at all. Always check what you actually have before assuming an install failed, and prefer an explicit version when you need one:
import shutil
import subprocess
import sys
# Ask the shell what each interpreter on PATH actually is.
for candidate in ('python', 'python3', 'python3.12'):
path = shutil.which(candidate)
if not path:
print(f'{candidate:<12} not on PATH')
continue
version = subprocess.run([candidate, '--version'], capture_output=True, text=True)
reported = (version.stdout or version.stderr).strip()
print(f'{candidate:<12} {path} -> {reported}')
print(f'{"this one":<12} {sys.executable} -> {sys.version.split()[0]}')
How do I install Python on Linux?
Linux usually already has a Python, so the question is whether it is new enough. Current Ubuntu releases ship a recent 3.x in the default repositories, so sudo apt install python3 python3-venv python3-pip is often all you need. Older releases may ship a version older than what this course assumes; in that case you have three sensible options.
- The distribution's own repository. Simplest, and it will be supported for the life of the release. Check first with
python3 --version. - A third-party repository of newer builds. For Ubuntu releases that lag behind, a maintained archive of extra interpreter versions lets you install a specific 3.12 build with apt. It works, but it is a repository you are trusting with root access, so read what you are adding.
- A version manager. Tools such as
pyenvbuild or download any interpreter on demand and let you switch per project with a single file in the project directory. This is the option that pays off when you juggle several projects.
There is one more that deserves a mention because it has become the default choice for a lot of new projects: uv, a fast installer and environment manager written in Rust. It can fetch an interpreter and create an environment in one step, and it is dramatically quicker than the classic pyenv build path because it downloads prebuilt interpreters rather than compiling them. If you are starting a fresh project on any platform and want one tool to handle interpreters and packages, this is a reasonable default in 2026.
How do you know the install actually worked?
Three checks, in increasing order of usefulness. First, ask the interpreter for its version. Second, ask pip for its version using python -m pip --version rather than bare pip, because the module form is guaranteed to use the same interpreter you just invoked. Third, run a script that prints everything about the environment, because that catches the cases where the version is right but the environment is not the one you expect.
import os
import sys
import sysconfig
def describe_environment():
print('interpreter :', sys.executable)
print('version :', sys.version.split()[0])
print('platform :', sys.platform)
print('prefix :', sys.prefix)
print('base prefix :', sys.base_prefix)
print('in a venv :', sys.prefix != sys.base_prefix)
print('packages :', sysconfig.get_path('purelib'))
print('working dir :', os.getcwd())
describe_environment()
The line worth reading twice is in a venv. When it prints False, you are running the system interpreter directly, which is exactly what you want right now but not what you want once third-party packages are involved.
Checking the package installer works as well:
import importlib.metadata as metadata
import subprocess
import sys
pip = subprocess.run(
[sys.executable, '-m', 'pip', '--version'], capture_output=True, text=True
)
print('pip reports:', (pip.stdout or pip.stderr).strip())
for package in ('pip', 'setuptools', 'wheel'):
try:
print(f'{package:<10}', metadata.version(package))
except metadata.PackageNotFoundError:
print(f'{package:<10}', 'not installed')
Your turn: install it and prove it works
- Install 3.12 (or newer) using the route for your system. On Windows, confirm the PATH checkbox was ticked during the python.org install, or use
winget install Python.Python.3.12. - Open a brand new terminal window and run
python --version. If that fails, runpy --versionon Windows orpython3 --versionon macOS and Linux. One of the three must work. - Save the two diagnostic scripts from this page as
check_env.pyandcheck_pip.py, run both, and read the output. Note the interpreter path and whether it sits inside a virtual environment. - Create a throwaway environment with
python -m venv practice, activate it, and runpython -c "import sys; print(sys.prefix)"again. The path now points inside thepracticefolder, which proves the isolation works. - Delete the folder when you are done. You now know how to create and throw away an environment without touching the system Python.
Quick reference
- Target Python 3.12 or newer; never install Python 2.
- On Windows, the "Add python.exe to PATH" checkbox is the single most important click during installation.
- Type
python -m piprather than barepipso the installer always matches the interpreter you invoked. - macOS ships an old
python3from the Xcode tools, so check the version before assuming an install worked. - If two versions fight over
python, use the launcher on Windows or a version manager on macOS and Linux.