This lesson walks you through installing Python 3.12 on every major platform, opening the REPL, running scripts, and using pip to install third-party packages. By the end you will have a working Python setup that you can use for the rest of the tutorial.
Install on Windows
Download the official installer from python.org. The installer offers two checkboxes on the first screen. Tick Add python.exe to PATH. Then choose Customize installation and ensure pip and the py launcher are selected. The default install location is fine for most users.
# Verify after install
PS> python --version
Python 3.12.4
PS> pip --version
pip 24.0 from C:\\Users\\you\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pip (python 3.12)
PS> py --version
Python 3.12.4
Install on macOS
Apple ships an older Python on macOS for system scripts. Do not use it. Install a fresh Python 3.12 with the official installer, or use Homebrew which is the standard macOS package manager. The Homebrew install also gives you pip and the venv module.
$ brew install [email protected]
$ python3.12 --version
Python 3.12.4
$ which pip3
/opt/homebrew/bin/pip3
Install on Linux
Most Linux distributions ship Python 3 in their package manager. On Ubuntu 22.04 the default is Python 3.10. Add the deadsnakes PPA for 3.12, or build from source. On Fedora 39 and later, Python 3.12 is in the default repositories.
# Ubuntu 22.04 with deadsnakes PPA
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.12 python3.12-venv python3.12-dev
$ python3.12 --version
Python 3.12.4
The REPL in detail
Open the REPL with python3 or python. Every expression you type is evaluated and the result printed. The underscore variable holds the last result so you can chain quick calculations. Use exit() or Ctrl-D to leave.
>>> 1 + 2
3
>>> _ * 10
30
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
...
Pip and virtual environments
Pip is the standard package installer. Always install project dependencies inside a virtual environment to avoid polluting the system Python. The venv module ships with Python 3.3+.
# Create a project folder and a venv
$ mkdir myproject && cd myproject
$ python3 -m venv .venv
$ source .venv/bin/activate # macOS / Linux
# .venv\Scripts\activate # Windows PowerShell
# Install a package into the active venv
(.venv) $ pip install requests
Successfully installed requests-2.32.3
# Save dependencies for reproducibility
(.venv) $ pip freeze > requirements.txt
Modern Python version managers in 2026
Once you have more than one project on your machine, you will inevitably need more than one Python version. Two tools solve this cleanly without touching your system Python. pyenv installs any Python version under your home directory and switches with a single command. uv is the newer Swiss-army-knife: it installs Python, manages virtual environments, resolves dependencies, and replaces pip, pip-tools, and virtualenv in one binary. Most teams in 2026 reach for uv first because it is roughly ten times faster than pip and has no Python bootstrap step.
# Install a specific Python with uv (no sudo required)
$ uv python install 3.12
$ uv python list
# Pin a project to that version
$ uv pin 3.12
# Create a venv and install deps from pyproject.toml in one step
$ uv sync
Pick one tool and use it consistently. Mixing system pip and uv-managed environments is the surest path to confusing errors about missing modules.
# Confirm the active interpreter from inside Python itself
import sys, sysconfig
print(sys.executable)
print(sys.version)
print(sysconfig.get_paths()["purelib"])
Common pitfalls during installation
Three installation mistakes account for most of the support questions beginners ask. First, on Windows, forgetting to tick Add python.exe to PATH leaves you unable to run python from any terminal. Re-run the installer, choose Modify, and enable that option. Second, on macOS, accidentally invoking /usr/bin/python3 instead of the Homebrew or uv-managed one creates a Frankenstein environment. Always run which python3 and python3 --version before installing packages so you know which interpreter is active. Third, installing packages with sudo pip install pollutes the system Python and may break your OS package manager on Linux. Never run pip with elevated privileges; create a virtual environment instead.
# A tiny diagnostic you can run inside a fresh venv
import importlib, subprocess
for pkg in ["requests", "click", "rich"]:
try:
importlib.import_module(pkg)
print(pkg, "OK")
except ImportError:
print(pkg, "missing -", subprocess.check_output(["pip", "install", pkg]).decode().strip())
How this compares to JavaScript and Node tooling
If you have used Node.js, Python's install story will feel familiar but slightly clunkier. nvm and fnm switch Node versions per shell; pyenv and uv do the same for Python. npm install reads package.json and writes to node_modules; pip install reads requirements.txt or pyproject.toml and writes to a venv site-packages. The big difference is defaults. JavaScript projects ship with a lockfile (package-lock.json or pnpm-lock.yaml) and one canonical install command. Python projects historically relied on requirements.txt without hashes, but uv and pip-tools have closed the gap with uv.lock and requirements.txt compiled from pyproject.toml. The REPL is also more powerful than node's interactive mode: it auto-indents on trailing colons, supports readline-style history, and exposes the inspect module so you can introspect any object's source from inside the session.
Summary
You now have Python 3.12, pip, and venv working on your machine. The next lesson covers variables, the basic data types, and how Python's type system differs from statically typed languages like Java.