PythonInstalling Python

Installing Python

Before you can write a single line of Python, you need a working Python interpreter on your machine. This sounds trivial, and mostly it is — but installing Python incorrectly is one of the most common reasons beginners get stuck before they even write "hello world". A missing PATH entry, a confusing python vs python3 command, or accidentally tampering with the Python your operating system depends on can all turn a five-minute setup into an hour of frustration.

This page walks through installing Python on Windows, macOS, and Linux, how to verify the install worked, and the gotchas that trip up almost everyone at least once.

Installing on Windows

On Windows, the most reliable way to install Python is to download the official installer from python.org/downloads. Grab the latest stable release, run the installer, and pay close attention to the very first screen.

Warning
On the first installer screen there is a checkbox at the bottom labeled "Add python.exe to PATH". Check this box. If you skip it, Python will still install, but your terminal won't know where to find it — running `python` will fail with something like `'python' is not recognized as an internal or external command`. This is, by a wide margin, the single most common mistake beginners make on Windows, and it's the source of countless "Python isn't working" questions online.

After checking the box, click "Install Now" and let the installer finish. If you already installed Python without checking that box, don't worry — you don't need to reinstall. You can either:

  • Re-run the installer and choose "Modify", then enable "Add python.exe to PATH", or
  • Manually add the Python install directory (and its Scripts subfolder) to your PATH environment variable via System Properties → Environment Variables.

The official installer also gives you two commands for free: python and the Python Launcher, py. The py launcher is Windows-specific and is handy when you have multiple Python versions installed, since py -3.12 will run a specific version directly.

Text
# After installation, open a new terminal (PowerShell or cmd) and run:
python --version
py --version
Installing on macOS

macOS ships with its own copy of Python preinstalled for internal system use, but you should not rely on it for your own projects. On recent macOS versions this system Python is old, sometimes missing entirely by default, and Apple can change or remove it in any OS update without warning. Treat it as "not yours to use."

There are two good ways to install a proper, user-controlled Python on macOS:

  • Download the official installer from python.org and run it like any other macOS .pkg installer — straightforward, but you'll need to re-download and re-run it each time you want to upgrade.

  • Install Homebrew (the popular macOS package manager) and then install Python through it, which makes upgrades a single command going forward.

Bash
# Install Homebrew first, if you don't already have it
# (see https://brew.sh for the official one-line install script)

# Then install Python with Homebrew
brew install python

# Upgrading later is just:
brew upgrade python
Note
Homebrew installs Python as `python3`, not `python`, which matches how most of the macOS and Linux world names the command. This is intentional — see the "python vs python3" section below.
Installing on Linux

Most Linux distributions ship with Python 3 preinstalled already, since many system tools and package managers themselves are written in Python. Before installing anything, it's worth checking what you already have.

Bash
# Check if Python 3 is already installed
python3 --version

If that command isn't found, or you want a newer version, install it through your distribution's package manager.

Bash
# Debian / Ubuntu and derivatives
sudo apt update
sudo apt install python3 python3-pip

# Fedora and other RPM-based distros
sudo dnf install python3 python3-pip

Notice that both commands install python3 explicitly, and python3-pip alongside it for package management. On Linux, the plain python command is often not installed at all — this is deliberate, and it's explained in the next section.

Verifying your installation

Whichever platform you're on, the next step is the same: open a fresh terminal window (important — a terminal opened before installation may not have picked up PATH changes yet) and check that Python and its package manager, pip, both respond.

Bash
python --version
python3 --version
pip --version

A healthy install prints something like this (your exact version number will differ):

Python 3.12.4
pip 24.0 from /usr/lib/python3.12/site-packages/pip (python 3.12)

If pip --version fails but Python itself works, try pip3 or python3 -m pip --version instead — some installations only expose the pip3 name, mirroring the python3 naming pattern.

The python vs python3 confusion

New Python users are frequently confused by the fact that the same tutorial's instructions don't work identically across machines. The reason is historical: Python 2 and Python 3 coexisted for many years, and to avoid breaking scripts that expected the old version, many operating systems reserved the plain python command for Python 2 (or removed it entirely) and used python3 for the new version.

Here's what that means in practice today:

  • On many Linux distributions and macOS (especially with Homebrew), python may not exist at all, or may point to an outdated Python 2 — always use python3 explicitly to be safe.

  • On Windows, the official python.org installer sets up both python and py to point at your installed Python 3, so python works as expected there.

  • Python 2 reached its official end of life years ago and should not be used for new projects under any circumstances — if a command runs and reports a 2.x version, that's a red flag, not a valid setup.

Note
When in doubt, get in the habit of typing `python3` and `pip3` (or `python3 -m pip`) instead of the bare `python`/`pip`. It's the one form that works consistently across Windows, macOS, and Linux, and it removes any ambiguity about which interpreter you're talking to.
System Python vs. your own Python

This is the most important habit to build early: your operating system may depend on its own internal copy of Python to run system tools, package managers, or scripts (this is especially true on Linux and, to a lesser extent, older macOS versions). That copy is not meant for your projects.

Warning
Never use `sudo pip install` (or otherwise modify packages inside the system Python) to install packages for your own projects. Upgrading, downgrading, or removing packages in the system Python can silently break OS-level tools that depend on specific versions — package managers, desktop utilities, even parts of the OS itself on some Linux distributions. The fix is not "be careful" — it's to never touch it directly. Install a separate, user-level Python (as shown above) for your own work, and use virtual environments to isolate each project's dependencies from both the system Python and each other.

We'll cover creating and using virtual environments properly in the next page, "Setting Up Your Environment" — for now, the takeaway is simple: the Python you installed for yourself is the one you run your projects with, and the one that came with your OS is off-limits.

Quick reference

OS

Recommended install method

Verify with

Windows

Official installer from python.org (check "Add python.exe to PATH")

python --version

macOS

Homebrew (brew install python) or the python.org installer

python3 --version

Linux (Debian/Ubuntu)

sudo apt install python3 python3-pip

python3 --version

Linux (Fedora)

sudo dnf install python3 python3-pip

python3 --version

Once python3 --version (or python --version on Windows) and pip --version both report sensible output, you're ready to move on. The next step is learning how to keep each project's dependencies isolated using virtual environments, so installing a package for one project never affects another — or your system.