This guide provides quick commands to activate and deactivate Python virtual environments across different platforms.
python -m venv venv
venv\Scripts\activate
# To deactivate:
deactivate
python -m venv venv
venv\Scripts\Activate.ps1
# To deactivate:
deactivate
python3 -m venv venv
source venv/bin/activate
# To deactivate:
deactivate
Removing a virtual environment is straightforward—just delete its directory. Here's how to do it on each OS:
Remove-Item -Recurse -Force .env
Or manually delete the folder using File Explorer.
rm -rf venv
Make sure you're in the parent directory of the virtual environment before running this command.
⚠️ Note: This action is irreversible. Ensure you no longer need the environment before deleting it.
✅ Tip: Always activate your venv before installing packages to keep dependencies isolated.
📦 To install packages: pip install <package-name>