Skip to content

Instantly share code, notes, and snippets.

Created Feb 11, 2020
What would you like to do?
Helper script to enable or disable a Python virtual environment
@echo off
if exist "%cd%\venv" (
if "%1" == "off" (
echo Deactivating virtual environment
call "%cd%\venv\Scripts\deactivate.bat"
) else (
echo Activating virtual environment
call "%cd%\venv\Scripts\activate.bat"
) else (
echo No venv folder found in %cd%.
Copy link

jgbishop commented Feb 11, 2020

This script makes it easy to enable or disable a virtual environment from a Windows shell (just make sure the script is somewhere in your PATH). A simple work command will enable the virtual environment, while work off will disable the virtual environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment