Run a python script in virtual environment from windows task scheduler -


i'm trying set recurring python task through windows task scheduler.

i have had success when input path 'python.exe' , provide script's path parameter windows task scheduler (see screenshot below)

windows task scheduler

however, want able choose particular virtual environment in run script. don't have knowledge of venv, , typically use opening cmd , running scripts\activate.bat in desired virtual environment directory.

how can accomplish 'run task x in venvxxx every 24 hours' using windows task scheduler?

create batch file these commands:

c:\__full_path_to_virtualenv__\scripts\activate.bat && python __full_path_to_python_script__.py 

&& means run command2 if command1 completed successfully.

then set batch file script run. don't need set additional arguments in task scheduler (or can set them in batch file anyway) , can set start in if script has read/write specific directory , uses relative paths.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -