Playwright + Python · Lesson 12 of 37
Module 12: Python Environment & Packages
Your task
Implement format_requirements_entry(package_name, version):
Write it in the editor, then press Check answer (Ctrl + Enter).
# 1. Create virtual environment:
python -m venv .venv
# 2. Activate environment:
# Windows PowerShell:
.venv\Scripts\Activate.ps1
# macOS / Linux:
source .venv/bin/activate
# 3. Install packages:
pip install selenium pytest
# 4. Freeze dependencies:
pip freeze > requirements.txt
# 5. Install from requirements file on CI:
pip install -r requirements.txtManaging Python environments with venv guarantees that your test framework dependencies do not conflict with system packages. In this lesson, you will master creating virtual environments, installing packages with pip, and freezing requirements.txt. Let's master environments!
Part of the Playwright + Python course (Playwright with Python). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
Pinning exact versions prevents breaking upstream changes from crashing your test runs unexpectedly on CI agents.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___