Installing Python 3.12 takes about five minutes on any major operating system. Most beginners who believe their install is broken actually have a PATH problem or a leftover Microsoft Store shortcut. This guide shows the Windows, macOS, and Linux steps one by one, the exact commands that confirm a working install, and two small scripts that prove which Python your terminal is really running.
The previous lesson in this module covered "What Is Python and Why Do Developers Choose It", and the next lesson in this module is about "Running Your First Python Program End to End".
Which Python should you install?
Install a current 3.x release. This course is written for Python 3.12 and runs in exactly the same way on 3.13 and 3.14, so any of those three is a fine choice. Do not install Python 2. It reached the end of its life in 2020, but some older tutorials still mention it, and Python 2 code behaves in ways that will waste your afternoon.
Two other choices are worth making early. First, install only the interpreter itself and keep third-party packages inside a virtual environment, which you will learn about later in this course. Second, if your operating system already ships its own Python, install yours next to it instead of trying to replace it. Some system packages depend on the version that came with the operating system, and breaking that version can stop unrelated tools from running on your machine.
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 read the very first screen carefully. Tick the box that says "Add python.exe to PATH". That single checkbox decides whether your terminal can run python or only tells you that the command is not found.
If you prefer to use a package manager, the Windows Package Manager has the official builds available:
winget install Python.Python.3.12installs the same interpreter and adds it to PATH for you.choco install python312does the same job under Chocolatey.
Two Windows traps catch people very often. The first one is the Microsoft Store version. If you install Python from the Store, Windows registers a shortcut called python.exe. Typing python in a terminal then opens the Microsoft Store instead of running your interpreter, and the terminal looks like it has hung. The fix is to uninstall the Store package, install from python.org, and check that the box at the bottom of the installer is ticked.
The second trap is having two interpreters at the same time. If you install 3.12 and 3.13 side by side, the plain python command runs whichever one was registered last. The Python Launcher solves this cleanly. The command py -3.12 --version runs one exact version no matter what your PATH says, and py -0 lists every version the launcher can see. The Windows installer offers the launcher by default, so accept it when you see it.
How do I install Python on macOS?
macOS gives you two easy routes, but only one of them gives you the exact version you asked for.
The python.org installer is the most predictable choice. Download the 3.12 macOS universal binary, open it, drag Python into your Applications folder, and close the window. It adds a command line tool under /Library/Frameworks/Python.framework/Versions/3.12/bin, and the installer offers to add that path to your shell. On recent versions of macOS the installer sets the path for you automatically.
Homebrew is the route that most developers use on macOS. The command brew install [email protected] installs the interpreter for you. Because versioned packages are kept separate by Homebrew, you usually need to add the folder to your path yourself or link it with brew link --force [email protected].
Here is the trap that catches almost everybody. macOS ships its own python3 command, which arrives with the Xcode command line tools, and it is usually an old release. On a brand new Mac, python3 --version can report a version that is several years old, and the plain python command usually says that it is not found at all. Always check what you really have before you decide that an install failed. When you need one exact version, ask for it by name:
import shutil
import subprocess
# Check which python commands are on PATH and what each one reports.
for name in ('python', 'python3', 'python3.12'):
path = shutil.which(name)
if path is None:
print(name, 'not found')
continue
result = subprocess.run([name, '--version'], capture_output=True, text=True)
print(name, '->', path, '->', (result.stdout or result.stderr).strip())
How do I install Python on Linux?
Linux usually has a Python already, so the real question is whether it is new enough. Current Ubuntu releases ship a recent 3.x version in their default repositories, so sudo apt install python3 python3-venv python3-pip is often all you need. Older releases may ship a version that is too old for this course, and in that case you have three sensible options.
- The distribution's own repository. This is the simplest option, and it stays supported for as long as the release does. Check it first with
python3 --version. - A third-party repository of newer builds. For Ubuntu releases that lag behind, a maintained archive lets you install a specific 3.12 build with apt. It works, but you are giving a third party root access to your machine, so read carefully what you are adding.
- A version manager. Tools such as
pyenvbuild or download any interpreter you ask for, and they let you switch between versions per project using one small file inside the project folder. This option pays off when you work on several projects at once.
One more tool deserves a mention, because many new projects now use it. uv is a fast installer and environment manager written in Rust. It can fetch an interpreter and create an environment in a single step, and it is much quicker than the classic pyenv build path because it downloads ready-made interpreters instead of compiling them from source. If you are starting a fresh project and you want one tool that handles both interpreters and packages, this is a reasonable default in 2026.
How do you know the install actually worked?
Run three checks, and each one tells you more than the one before it. First, ask the interpreter for its version. Second, ask pip for its version using python -m pip --version instead of plain pip, because the module form always uses the same interpreter that you just called. Third, run a script that prints the whole environment, because that last check catches the case where the version looks correct but the environment is not the one you expected.
import os
import sys
print('interpreter :', sys.executable)
print('version :', sys.version.split()[0])
print('platform :', sys.platform)
print('working dir :', os.getcwd())
# These two paths are the same when you run the system Python.
print('in a venv :', sys.prefix != sys.base_prefix)
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 and not what you want once you start installing third-party packages.
Then check that the package installer works as well:
import subprocess
import sys
# Use the module form so pip always matches this Python.
result = subprocess.run(
[sys.executable, '-m', 'pip', '--version'],
capture_output=True, text=True
)
print('pip reports:', (result.stdout or result.stderr).strip())
Your turn: install it and prove that it works
- Install 3.12 or newer using the steps for your system. On Windows, check that the PATH box 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 those three commands must work. - Save the two scripts from this page as
check_env.pyandcheck_pip.py. Run both of them and read the output. Note the interpreter path, and note whether it sits inside a virtual environment. - Create a test environment with
python -m venv practice, turn it on, and runpython -c "import sys; print(sys.prefix)"again. The path now points inside thepracticefolder, which proves that 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 at all.
Quick reference
- Install Python 3.12 or newer, and never install Python 2.
- On Windows, the "Add python.exe to PATH" checkbox is the most important click in the whole installation.
- Type
python -m pipinstead of plainpip, so that the installer always matches the interpreter you called. - macOS ships an old
python3from the Xcode tools, so check the version before you assume that your install worked. - If two versions fight over the
pythoncommand, use the launcher on Windows or a version manager on macOS and Linux.