Skip to content
Learn Netverks

Lesson

Step 33/36 92% through track

virtual-environments

Virtual environments

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Virtual environments: the syntax, patterns, and safety habits you need before advancing in Python.

Teams still ship Virtual environments in Python codebases—skipping it leaves gaps in debugging and code reviews.

You will apply Virtual environments in contexts like: Scripts, Django/FastAPI apps, notebooks, and glue code between systems.

Write Python 3 in the editor and click Run on server—the dev runner executes your script with print() for output; stdlib only in playground snippets (LEARNING_RUNNER_ENABLED=true).

Toward the end of the track—consolidate before capstone-style review lessons.

Virtual environments isolate project dependencies—each venv has its own python and pip. Modern workflows also use pyproject.toml with tools like Poetry or uv locally; venv remains the stdlib baseline.

Workflow recap

  1. python3 -m venv .venv
  2. Activate (source .venv/bin/activate on macOS/Linux)
  3. pip install -r requirements.txt
  4. Run tests and apps with the venv Python

Why isolation matters

Project A may need Django 4.2 while Project B needs Django 5.x—global installs create dependency hell. Same lesson as node_modules per app in JavaScript.

Important interview questions and answers

  1. Q: venv vs Docker?
    A: venv isolates Python packages on one machine; Docker isolates OS-level runtime and system deps for deploy parity.
  2. Q: How know active venv?
    A: Prompt prefix (.venv) and which python points inside the venv directory.

Self-check

  1. What module creates a venv?
  2. Why not install all projects into system Python?

Tip: Commit requirements.txt or lockfile—not the .venv folder itself.

Interview prep

venv vs Docker?

venv isolates Python packages; Docker isolates OS/runtime for deploy parity.

Detect active venv?

Shell prompt prefix and which python inside .venv/bin.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • venv vs conda?
  • Activate how?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump