Setting Up Python
Installing Python, confirming it works, and understanding what pip and virtual environments are for.
2 min read
Before writing any Python, you need the interpreter installed and a way to confirm it's actually on your system's PATH. This lesson covers installation and the two tools you'll reach for constantly afterward: pip and virtual environments.
Installing Python
Most systems don't ship with a recent Python version by default (and macOS's built-in python3 is often outdated for real project use). Download the latest version from python.org for Windows and macOS. On Linux, your package manager usually has it: sudo apt install python3 on Debian/Ubuntu, for example.
During installation on Windows, check the box labeled "Add python.exe to PATH" — skipping this is the single most common reason python "isn't recognized" afterward.
Confirming the install
Open a terminal and run:
python --versionOn some systems (particularly macOS and Linux, where python may still point to Python 2 or nothing at all), use python3 instead:
python3 --versionEither should print something like Python 3.12.1. If you get a "command not found" error, the installer either didn't add Python to your PATH or the terminal needs restarting to pick up the change.
pip: Python's package manager
pip comes bundled with modern Python installs and is how you install third-party libraries:
pip install requestsThis downloads the requests library (a popular tool for making HTTP calls) and makes it available to import in your code. Check what's installed with pip list, and see pip's own version with pip --version.
Virtual environments
Installing every project's dependencies globally is a recipe for version conflicts — Project A needs django==4.2 while Project B needs django==5.0. A virtual environment gives each project its own isolated set of installed packages:
python -m venv venvThis creates a venv/ folder holding an isolated Python environment. Activate it before working:
# macOS/Linux
source venv/bin/activate
# Windows
venv\Scripts\activateYour prompt will show (venv) once it's active, and any pip install from that point only affects this project. Run deactivate to leave it. It's standard practice to create a fresh virtual environment per project and never commit the venv/ folder itself to version control — only a requirements.txt listing what's needed (covered in the modules and packaging lesson later in this course).
A quick sanity check
With Python installed, open a terminal and start the interactive shell just by typing python (or python3). You'll land in a >>> prompt where you can type expressions and see results immediately — a fast way to experiment before committing anything to a file. Type exit() to leave it.
Test what you just learned
4 quick questions. Get all of them right to unlock the next lesson.
You can take the quiz without an account — logging in just lets your result count toward your progress.