Install Python
Tutorial 2 of 65 · pythondeck.com Python course
Install the latest CPython from python.org. On Windows enable Add Python to PATH during setup; on macOS brew install python is convenient; on Linux use the distribution package manager (e.g. sudo apt install python3 python3-pip python3-venv). Verify with python --version and pip --version. For project isolation always work inside a virtual environment.
A correct Python installation gives you the interpreter, pip, and optionally the py launcher on Windows. Without a known-good setup, tutorials fail at the first command and beginners blame the language instead of PATH or version mismatches.
Install methods differ by OS: installers from python.org, package managers on Linux, and Homebrew on macOS. The goal is one default python3 (or py -3) that matches documentation you follow.
Download from python.org or use a trusted package manager; avoid random repackaged builds.
On Windows, check Add python.exe to PATH during setup or configure PATH manually afterward.
python -m pip is the supported way to invoke pip tied to that interpreter.
Virtual environments (python -m venv .venv) isolate dependencies per project.
IDEs can point to a specific interpreter; mismatched IDE and terminal Python cause import errors.
Optional tools: pyenv, asdf, or uv for managing multiple versions.
Multiple Python versions on one machine are normal. Use py -3.12 on Windows or explicit paths in shebangs and CI configs so scripts do not accidentally run on an older system Python.
Corporate machines may block installers; in that case, portable builds or WSL provide a consistent Linux environment. Document the exact install steps your team reproduces.
After install, verify with python -c "import sys; print(sys.executable)" so you know which binary runs when you type python.
Running pip install without python -m pip and hitting the wrong interpreter.
Disabling PATH on Windows then wondering why python is not recognized.
Upgrading system Python on Linux and breaking distro tools that depend on the packaged version.
Installing Anaconda for a beginner course that only needs CPython and venv.
Prefer per-project .venv folders and add them to .gitignore.
Pin Python version in README and CI (e.g. 3.12) to match local development.
Use python -m venv rather than copying site-packages between machines.
Re-run a three-line smoke test after any install or PATH change.
Re-read the examples below with these ideas in mind; change variable names and inputs to match your own project.
The program below demonstrates check version. Read the comments on each line, run the code, then change names or values to see how the output shifts.
# Example: Check version
# Run in the REPL or save as a .py file and execute with python.
python --version
pip --version
This sample walks through create venv in a small, runnable script. Paste it into the REPL or save it as a .py file before you continue to the next block.
# Example: Create venv
# Run in the REPL or save as a .py file and execute with python.
python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS / Linux:
source .venv/bin/activate
Here is a hands-on illustration of install a package. Follow the inline comments first; only then execute the snippet and compare the result with what you expected.
# Example: Install a package
# Run in the REPL or save as a .py file and execute with python.
pip install requests
python -c "import requests; print(requests.__version__)"
The program below demonstrates verify interpreter. Read the comments on each line, run the code, then change names or values to see how the output shifts.
# Windows: py -3 macOS/Linux: python3
python --version # should print Python 3.10+ for modern tutorials
python -c "import sys; print(sys.executable)" # confirm which binary runs
python -c "import ssl; print(ssl.OPENSSL_VERSION)" # TLS stack present
where python # Windows: show PATH resolution (which python on Unix)
python -m pip --version # pip must belong to the same interpreter
python -m venv .venv # create an isolated environment in current folder
# Activate before installing packages (paths differ by OS)
echo After activate, which python should point inside .venv
This sample walks through smoke test venv in a small, runnable script. Paste it into the REPL or save it as a .py file before you continue to the next block.
# After: source .venv/bin/activate (or .venv\Scripts\activate)
python -m pip install --upgrade pip # newest pip avoids resolver bugs
python -m pip install requests # small dependency for a smoke test
python -c "import requests; print(requests.__version__)" # import proves install
python -c "import sys; print(sys.prefix)" # prefix should be inside .venv
pip list # inventory packages visible to this environment only
pip freeze > requirements-smoke.txt # pin file for reproducible installs
type requirements-smoke.txt # Windows: display file (cat on Unix)
deactivate # leave venv; system/python global interpreter returns