venv & pip
beginner10 min readLesson 42 of 169
Create, activate, install — and pin versions with requirements.txt.
pip is the installer; PyPI (pypi.org) is the public package catalog it downloads from.
pip install rich # latest version
pip install "requests==2.31.0" # exact version — reproducible
pip list # what is installed here
requirements.txt — your project's recipe
rich==13.7.1
requests==2.31.0
Freeze what you installed:
pip freeze > requirements.txt
Rebuild the environment anywhere (a teammate's laptop, a server):
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Version pins are a kindness to your future self and your teammates: "it works on my machine" becomes "here is the exact recipe that works."