Jonathan Lam

Core Developer @ Hudson River Trading


Blog

pip venvs and freezing

On 4/18/2021, 6:52:54 PM

Return to blog


Notes for my own reference. I don't like pip (I prefer npm with its implicit local environments and don't find any of the following command names particularly intuitive) but had to use it for a group project today.

Virtual environments:

# creating virtual environment in venv/
python -m venv venv

# activating venv
. venv/bin/activate

# deactivating venv
deactivate

# destroying venv
rm -rf venv

Saving/restoring dependencies

Make sure you're in the venv when doing these.

# freezing dependencies
pip freeze >requirements.txt

# installing dependencies
pip install -r requirements.txt

© Copyright 2023 Jonathan Lam