简体   繁体   English

如何通过任务计划程序计划从虚拟环境运行的python脚本

[英]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.

相关问题 当没有activate.bat并且我是凡人时,如何在虚拟环境中的任务调度程序中运行 python 脚本 - How do I run a python script in task scheduler in a virtual environment when there is no activate.bat and I'm mortal 无法安排 python 脚本通过 Windows 任务计划程序运行 - Cannot schedule a python script to run through Windows Task Scheduler 如何在没有cmd的虚拟环境中使用python运行python脚本 - How to run python script with python from virtual environment without cmd 通过 Windows 任务计划程序安排在 Anaconda 中开发的脚本 - Schedule a script developed in Anaconda via Windows Task Scheduler 在 Windows 上的任务计划程序中计划并手动运行 .pyw 脚本 - Schedule and MANUALLY run .pyw script in Task Scheduler on Windows 批处理文件中的Python脚本无法在任务计划程序中运行 - Python script from batch file won't run in task scheduler 我的 Python 脚本无法从任务计划程序运行 - My Python Script does not run from Task Scheduler 如何安排从anaconda运行的python脚本? - How to schedule python script run from anaconda? 如何使用带参数的任务计划程序运行 python 脚本 - How to run a python script using Task Scheduler with parameters 使用Windows任务计划程序安排[Virtualenv相关] Python脚本 - Schedule [Virtualenv Dependent] Python Script with Windows Task Scheduler
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM