16.1 Creating environments using the built-in venv
Once Python is installed, creating virtual environments unique to each project can be done with the internal venv module.
There are two principle use cases for a virtual environment:
Manage the Python version. We might have distinct virtual environments for Python 3.12 and Python 3.13. In some cases, we may need to manage multiple minor releases of Python 3.13.
Manage the mix of site-specific packages required by our project. Rather than trying to update the single actual environment, we can create new virtual environments as new releases of packages become available.
These two use cases overlap a great deal. Each release of Python will have distinct versions of the standard library packages and may have distinct versions of external site-specific packages.
The most important part of using a virtual environment is making sure that it has been activated. A number of scenarios...