1. Concept library
  2. Python Foundations
  3. Module 8: Modules and packages

Concept

Virtual environments

A virtual environment is a private copy of Python and its packages for one project, so two projects can need different versions without fighting. It is the first thing to create in any new project.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain what a virtual environment holds and why each project needs one
  2. Create and activate an environment, install a package and record it
  3. Spot why pip install worked but import failed, by checking which python runs

In practice

A few lines that show Virtual environments doing its job.

Bash
python -m venv .venv
source .venv/bin/activate      # Windows: .venv\Scripts\activate
pip install requests
pip freeze > requirements.txt

# later, on another machine
pip install -r requirements.txt

The common mistake

Watch for

Installing packages without activating the environment, so they land in the system Python. If pip install works but import fails, check which python is running.

What to know first

Your roadmap puts these before Virtual environments, unless you already know them.

How it stays learned

Once a session shows you understand Virtual environments, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled
Previous in the module← Imports
Next in the moduleThe standard library →