问题
I want to schedule a python script to start at 3AM and break at 5PM every weekday. However the problem arises when I need to start virtualenv as all the packages are install in a virtual environment. I can get it to run at a specific time, however I can't activate the virtual environment (I'd normally type "env\scripts\activate"). Here is what my action looks like:
Any idea on how I can incorporate activating virtualenv and what my action should looks like to break the script? Thanks
回答1:
Execute a batch script (test.bat) instead of calling python.exe
Create such test.bat by copying activate.bat file. At the end of the test.bat add calling python.exe with your own python file.
来源:https://stackoverflow.com/questions/40412771/schedule-virtualenv-dependent-python-script-with-windows-task-scheduler