Programming foundations

Stage 6 · Lesson 2 of 8

Virtual environments and pip

Build and ship your first projects

A is a private folder of packages for one project. It stops projects fighting over versions, and nothing gets installed for the whole system. Create one with python -m venv .venv and then activate it: source .venv/bin/activate on macOS and Linux, or .venv\Scripts\activate on Windows.

Then install what you need with pip, such as pip install requests. Record the list with pip freeze > requirements.txt. A stranger then recreates it with pip install -r requirements.txt.

Add .venv to .gitignore. Newer tools such as uv and wrap the same ideas around a pyproject.toml and a . Either is fine, but learn the plain venv and pip flow first, so you know what they automate.

A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

Keep handy

  • Free APIs that give a small project real data to work with

Also worth your time

Mark this stage as not done?