CoursePython from Scratch to Intermediate · Module 7: Modules, the Standard Library and Packages · part 49 of 75
Part 49 · Module 7: Modules, the Standard Library and Packages

Lesson 4: pip and virtual environments, packages kept per project

13 min read·14 Oct 2026
Module 7 · Lesson 4 · About 45 minutes · Needs: Module 7 Lessons 1 to 3 (import, the standard library), and !python from Module 1 Lesson 2

The situation

Everything Booknook has used so far came with Python. Module 10 tests the shelf's rules with pytest, a tool that does not: it must be fetched from the internet and installed.

Amira adds a condition. "Tom will run the tests on the café laptop, and you run them in Colab. I want both of you to get the same answer." That means the same pytest, at the same version, on both computers, without disturbing anything else on them.

This lesson follows one package, pytest 9.1.1, from the internet into a private folder made for Booknook alone.

requirements.txt pytest==9.1.1 pip fetches it booknook-env pytest 9.1.1 the same file builds the same environment anywhere
The lesson in one line: requirements.txt names pytest 9.1.1, pip fetches it, and it lands in booknook-env, Booknook's own environment (blue is your project, green is installed).

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.