A virtual environment creates an isolated workspace for your Python project. Whether you’re working solo or with collaborators, having a virtual environment is helpful for the following reasons:
- Avoiding package conflicts
- Providing clear line of sight on where packages are being installed
- Ensuring consistency in package version utilized by the project
The use of a virtual environment allows you (and your teammates) to have different dependencies for different projects. Within the virtual environment, you can test install packages without polluting the system install.
Deploying the venv module is seriously helpful for avoiding issues down the line, so don’t skip this step when getting started with your project.
Read more: save space — and avoid installing the same version of multiple packages in different places — by setting up a virtual environment that contains the most commonly used packages for scientific computing. Then share that common environment as a .pth file across project-specific environments.