从Windows Task Scheduler在虚拟环境中运行python脚本

希望

我正在尝试通过Windows Task Scheduler设置一个重复执行的Python任务。

当我输入“ python.exe”的路径并将脚本的路径作为Windows Task Scheduler的参数提供时,我已经成功了(请参见下面的屏幕截图)

Windows任务计划程序

但是,我希望能够选择在其中运行脚本的特定虚拟环境。我对venv不太了解,通常通过打开cmd并在所需的虚拟环境目录中运行Scripts \ activate.bat来使用它。

如何使用Windows Task Scheduler完成“每24小时在venvxxx中运行任务x”?

mx0

使用以下命令创建批处理文件:

c:\__full_path_to_virtualenv__\Scripts\activate.bat && python __full_path_to_python_script__.py

&&表示如果command1成功完成,运行command2

然后将该批处理文件设置为要运行的脚本。如果脚本必须从特定目录读取/写入并使用相对路径无需在任务计划程序中设置任何其他参数(也可以在批处理文件中设置它们),也可以设置Start in

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Windows Task Scheduler(Windows 7)中运行Powershell脚本

无法通过Windows Task Scheduler运行我的python脚本

通过Windows Task Scheduler运行Powershell脚本

Windows中调用python脚本时自动开启虚拟环境

Spyder无法在Windows 10的Anaconda虚拟环境中运行

Windows Task Scheduler图表?

使用Windows Task Scheduler运行PHP脚本,包括文件失败

PowerShell脚本无法从Windows Task Scheduler中正常运行

在Windows上激活Python虚拟环境

在 Windows 10 中安装虚拟环境

Windows Task Scheduler无法运行VBScript

从Windows Task Scheduler自动运行curl

WebApi中的Windows Task Scheduler或TaskService函数

在Windows中激活python虚拟环境时设置环境变量

如何在Windows 7的虚拟环境中运行py文件?

Windows Scheduled Task拒绝运行

通过Windows Task Scheduler运行脚本时,隐藏命令行窗口的PowerShell代码行?

Windows Task Scheduler,如果任务未运行,请运行任务?

如何在Python3.5虚拟环境中安装scipy Windows 10?

从Windows Task Scheduler启动Invantive Data Hub脚本

创建新的虚拟环境python Windows 10时出错

在Windows 10中静默创建conda虚拟环境

如何在 Windows 中激活我的虚拟环境?

使用Windows Task Scheduler运行批处理文件

如何使用Windows Task Scheduler来运行UpdatedB?

Windows Task Scheduler未在事件上运行任务

Windows Task Scheduler上的文件更改

在Windows Task Scheduler上进行计划

Windows .NET上的Task Scheduler的问题