[英]How to schedule a python script to run from virtual environment via task scheduler
I stumbled on an answer for basically the exact same question, but either I am implementing the solution wrong, the solution is no longer accurate, or some other issue is at play. 我偶然发现了一个基本相同的问题的答案,但是要么我实施的解决方案错误,解决方案不再准确,要么其他问题在起作用。
Run a python script in virtual environment from windows task scheduler 从Windows Task Scheduler在虚拟环境中运行python脚本
I used the code from above link, edited for my directories, and copied directly into the task scheduler program/script prompt. 我使用了上面链接中的代码,为目录进行了编辑,然后直接复制到了任务计划程序的程序/脚本提示符中。
C:\Users\I511843\myenv\activate.bat && python C:\Users\I511843\Desktop\Atom_scripts\test.py
I then set the program to run every time I unlocked the machine. 然后,我将程序设置为在每次解锁计算机时都运行。 The program simply writes a text file called test.txt containing the text "success!" 该程序只需编写一个名为test.txt的文本文件,其中包含文本“成功!”。
The text file populates in the correct directory when I run from the command line, however, the program doe snot execute from the task scheduler. 当我从命令行运行时,文本文件将填充在正确的目录中,但是该程序不会从任务计划程序中执行。
Did you try putting the commands in a batch file and executing the batch file from task scheduler? 您是否尝试将命令放入批处理文件中并从任务计划程序执行批处理文件? Something like below: 如下所示:
C:\\Users\\I511843\\myenv\\activate.bat && python C:\\Users\\I511843\\Desktop\\Atom_scripts\\test.py
goes into task.bat file. C:\\Users\\I511843\\myenv\\activate.bat && python C:\\Users\\I511843\\Desktop\\Atom_scripts\\test.py
进入task.bat文件。
In task scheduler, run task.bat
from cmd. 在任务计划程序中,从cmd运行task.bat
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.