Python5 min read
Python Virtual Environments
Isolate project dependencies using virtual environments.
Michael Brown
December 18, 2025
0.0k0
Manage project dependencies.
Create Virtual Environment
```bash # Create venv python -m venv myenv
Activate (Windows) myenv\Scripts\activate
Activate (Mac/Linux) source myenv/bin/activate ```
Install Packages
```bash # Install package pip install requests
Install specific version pip install django==4.2
Install from requirements.txt pip install -r requirements.txt ```
Save Dependencies
```bash # Create requirements.txt pip freeze > requirements.txt
Contents example: # requests==2.31.0 # django==4.2.0 ```
Deactivate
```bash deactivate ```
Why Use Virtual Environments?
- Isolate project dependencies - Avoid version conflicts - Easy to share project setup - Keep global Python clean
Remember
- One venv per project - Always activate before work - Add venv to .gitignore
#Python#Intermediate#Virtual Env