Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jgbishop
Created February 11, 2020 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgbishop/dc65e0612b6b81dd615f7bfdcef7632f to your computer and use it in GitHub Desktop.
Save jgbishop/dc65e0612b6b81dd615f7bfdcef7632f to your computer and use it in GitHub Desktop.
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"
echo.
) else (
echo Activating virtual environment
call "%cd%\venv\Scripts\activate.bat"
)
) else (
echo No venv folder found in %cd%.
)
@jgbishop
Copy link
Author

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