What is a virtual environment?
In Python, a virtual environment lets you install packages in an isolated location – usually for a specific application – instead of globally. This lets each application have its own isolated environment with only the packages it needs.
Managing virtual environments with a requirements.txt file
It seems like Pipenv is the best approach for python package management. But lots of projects still manage virtual environments using a workflow like this:
- Activate a virtual env when working on a project.
- Install packages using
pip install <package>.
- Update requirements.txt using
- Commit updates to
- Activate different virtual env when working on a different project.
Make sure you’ve installed
virtualenv globally with
pip install virtualenv.
Create virtual env
python -m virtualenv <name>
If you’ve already activated a venv, you’ll have access to the
- When you activate a virtual env, it seems like the virtual env’s
bindirectory gets added to your path. This is why you have access to commands like
deactivate(which lives at