Run a python script in virtual environment from windows task scheduler

后端 未结 5 1709
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 20:48

I\'m trying to set up a recurring Python task through windows task scheduler.

I have had success when I input the path to \'python.exe\' and provide the script\'s pa

5条回答
  •  -上瘾入骨i
    2020-12-03 21:21

    Create batch file with 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 that batch file as script to run. You don't need to set any additional arguments in task scheduler (or you can set them in batch file anyway) and can set Start in if script has to read/write from specific directory and uses relative paths.

提交回复
热议问题