简体   繁体   中英

How do I schedule a python script (main.py from Github Rep) in anaconda ssf environment?

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?

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" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM