0

I am trying to schedule a Github repo in conda ssf environment of python using windows scheduler.

I checked this link A python script in virtual environment from windows task scheduler, but I cannot run it.

Queries: Where do I save the bat file?

Also, will it open the conda ssf environment and then run the script?

  • 2
    Possible duplicate of [Run a python script in virtual environment from windows task scheduler](https://stackoverflow.com/questions/34622514/run-a-python-script-in-virtual-environment-from-windows-task-scheduler) – SimonF Nov 27 '19 at 08:27

1 Answers1

0

First you need to add Anaconda path to the environment variable. anaconda base path and <anaconda base path>/Scripts to the environment variable.

Then you can execute conda commands through your cmd

next step is writing the batch file.when your batch file is running there are few things to execute

  1. find the python.exe path
  2. find the actual python script path
  3. run the activate.bat file in anaconda
  4. activate the environment
  5. execute the python script

batch file look like this

@ECHO on

call <anaconda_dir>\Scripts\activate.bat
call activate <environment name>
"C:\Program Files\python\Python.exe"  "<path to your script\script.py" 

PAUSE

notes - you can save bat file anywhere if you specified absolute path in "<path to your script\script.py".

Rajith Thennakoon
  • 3,975
  • 2
  • 14
  • 24
  • Thank you for your reply. What I understand is, I need to make one batch file with file name activate.bat and I have saved it in conda script folder.Would that work? I definitely tried it, but not getting as expected – Prashant Kumar Nov 27 '19 at 09:24
  • no,activate.bat is already inside the anaconda installation folder. you need to create separate batch file .script is written in the answer. when you run your batch file,it will execute the activation.bat file,and activate the given environment and run your python script accordingly. – Rajith Thennakoon Nov 27 '19 at 12:17
  • you don't need to store your batch file inside the Scripts folder.. – Rajith Thennakoon Nov 27 '19 at 12:18
  • Thank you, I shall be able to take it further from here. – Prashant Kumar Nov 28 '19 at 07:06