Virtual Environments
Python - A Quick Start for existing Programers
2 min read
Published Sep 16 2025, updated Sep 30 2025
Guide Sections
Guide Comments
A virtual environment is a self-contained directory that isolates a Python interpreter and its packages from the global Python installation. This lets you work on different projects without conflicts between package versions.
Why Use Virtual Environments?
- Dependency isolation - Each project can have its own packages and versions, avoiding conflicts.
- Avoid polluting global Python - Keeps your system Python clean and avoids breaking system tools.
- Reproducible environments - Makes it easier to share projects; you can create a
requirements.txtto replicate the environment elsewhere. - Supports multiple Python versions - You can use different Python interpreters for different projects.
How to Set Up a Virtual Environment
Make sure the virtual environment folder is added to your .gitignore file so that environment packages aren't included in your repository.
Install any packages required as normal, these will now be stored locally in the virtual environment and only available to that project, not globally, eg:
To detail which packages are required for a project, you can create a requirements.txt list, to record what packages are required and to easily install them, which is useful when sharing a project with others.
Create the requirements.txt file with:
Install all packages in requirements.txt with:
Returns you to the system Python environment:














