Created
February 11, 2020 14:28
-
-
Save jgbishop/dc65e0612b6b81dd615f7bfdcef7632f to your computer and use it in GitHub Desktop.
Helper script to enable or disable a Python virtual environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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%. | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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, whilework off
will disable the virtual environment.