
Quiz
Virtual Environments & pip
Project A needs rich 12 and project B needs rich 13. If you install
everything into one shared Python, they'll fight. A virtual
environment (venv) gives each project its own private set of
packages.
python -m venv .venv # create it (once per project)
source .venv/bin/activate # macOS / Linux
.venv\Scripts\activate # Windows
python -m pip install rich # installs into .venv only
python -m pip install -e . # install YOUR project, editable
deactivate # leave the venv
- Activating puts the venv's
pythonandpipfirst on your PATH. python -m pipmakes sure you use the pip that belongs to that Python.-e(editable) links to your source, so edits take effect without reinstalling.- pip does not edit
pyproject.tomlfor you. You list the dependencies there yourself. Lock files orpip freezerecord exact versions. - Never commit
.venv/to git. It's easy to rebuild.
Pip tip: Modern tools like
uvdo all of this very quickly, but the ideas are the same: one isolated environment per project.