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.
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
Scriptssubfolder) 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.
# 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.
# 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
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.
# 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.
# 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.
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),
pythonmay not exist at all, or may point to an outdated Python 2 — always usepython3explicitly to be safe.On Windows, the official python.org installer sets up both
pythonandpyto point at your installed Python 3, sopythonworks 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.
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.
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 ( | python3 --version |
Linux (Debian/Ubuntu) |
| python3 --version |
Linux (Fedora) |
| 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.