Manuals / Python / Chapter 2

A · Setup · beginner · Week 1 · Chapter 2 of 13

Virtual environments & toolchain

Never pollute global Python. venv per project. pip install inside venv. requirements.txt for reproducibility.

Path progress
10%

Step 1 of 3

Create and activate venv

python -m venv .venv creates an isolated environment. Activate before every session.

Create and activate venvDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →Create and activatdrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

python -m venv .venv

# macOS / Linux
source .venv/bin/activate

# Windows
.venv\Scripts\activate

python --version
pip --version

Do this now

Create .venv in py-journey. Activate. Run which python (or where python on Windows).

Was this step clear?
Chapter learning outcomes
  • python -m venv
  • activate/deactivate
  • pip install
  • requirements.txt

Clear these before you leave

Side quest

Fresh clone drill

Delete .venv, recreate, pip install -r requirements.txt — still works.