Skip to content

Instantly share code, notes, and snippets.

@rokdd
Created September 8, 2021 21:05
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 rokdd/b2f5e7619f9921862206d2e80861637b to your computer and use it in GitHub Desktop.
Save rokdd/b2f5e7619f9921862206d2e80861637b to your computer and use it in GitHub Desktop.
Run python script with virtual envoirement in windows
@echo off
rem this scripts start a python script with a virtual envoirement (venv) from commandline
rem for improvements or questions contact www.rokdd.xyz
rem ------
rem please put your path of the virtual envoirement here (the directory contains a activate.bat):
set path_env=C:\<....>\Scripts
rem then we will add the path to the global PATH (you can also add more libraries from other directorys)
set PATH=%path_env%;%PATH%
rem remove the rem of next line when you want to use anaconda
rem call C:\Users\<username>\anaconda3\condabin\activate "<your env name>"
rem activate the envoirement
call "%path_env%\activate.bat"
rem now we forward to python to the path including all arguments
"%path_env%\python.exe" 000-latest\main.py %*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment