62
Modern Dev Environment
Python Dev Environment: Make It Runnable, Reproducible, and Collaborative
What you're probably confused about right now
"It runs on my machine. That's enough, right?"
It's not. You also need your teammates -- and your future self -- to reproduce the setup reliably.
One-line definition
Standardizing a dev environment means pinning Python versions, dependencies, and tooling so a project is reproducible.
Real-life analogy
Like writing a recipe: exact steps and measurements so anyone can recreate the dish.
Minimal working example
python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install requests
pip freeze > requirements.txt
Quick quiz (5 min)
- Initialize and activate a venv.
- Export the dependency list.
- Restore the environment in a new directory.
Quiz answer guide & grading criteria
- Answer direction: write runnable code that covers the core requirements and edge cases from the prompt.
- Criterion 1 (Correctness): Main flow produces correct results, key branches execute.
- Criterion 2 (Readability): Clear variable names, no excessive nesting.
- Criterion 3 (Robustness): Basic protection against null values, type errors, or unexpected input.
Take-home task
Take one of your existing script projects and add a proper .venv + requirements.txt setup.
Acceptance criteria
You can independently:
- Create an isolated environment
- Export and restore dependencies
- Select the correct interpreter in your IDE
Common errors & debugging steps (beginner edition)
- Can't read the error: start from the last line -- find the error type (
TypeError,NameError, etc.), then trace back to the line in your code. - Not sure about a variable's value: throw in a temporary
print(var, type(var))at key points to verify data looks right. - Changed code but nothing happened: make sure the file is saved, you're running the right file, and your terminal is in the correct venv.
Common misconceptions
- Misconception: just use the global environment for everything.
- Reality: environment isolation is basic engineering hygiene.