无法通过 Windows 任务调度程序运行我的 python 脚本 [英] Unable to run my python script through windows task scheduler

查看:46
本文介绍了无法通过 Windows 任务调度程序运行我的 python 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 anaconda 包,并且可以直接从控制台轻松地运行 python 笔记本和 python 脚本.我创建了一个脚本并希望它每天在特定时间段运行,但它不起作用.所以我创建了一个简单的测试文件来检查哪里出了问题.这是我的测试文件

I have installed the anaconda package and been running python notebooks and python scripts easily directly from console. I created a script and want it to run every day at particular time period but it did not work. So I created a simple test file to check what is wrong. This is my test file

print("enter the no to exit")
input()

当我在命令提示符下运行这个程序时,它会要求我输入然后退出.

When I run this program on command prompt it ask me for an input and then it exit.

我按照本教程每天使用 Windows 调度程序运行该程序 https://blogs.esri.com/esri/arcgis/2013/07/30/scheduling-a-scrip/

I followed this tutorial to run this program daily using windows scheduler https://blogs.esri.com/esri/arcgis/2013/07/30/scheduling-a-scrip/

在操作选项卡中我写了这个

In action tab I wrote this

"C:\Anaconda3\python.exe"

"C:\Anaconda3\python.exe"

而论据为

"E:\test.py"

"E:\test.py"

当我手动运行任务时,会弹出一个黑色窗口并自动关闭,我无法弄清楚出了什么问题.我看到它说类似无效目录.我不知道我做错了什么.请帮忙.

And when I run the task manually a black window pop up and automatically closed, I cannot figure out what is wrong. I see it say something like invalid directory. I don't know what am I doing wrong. Please help.

推荐答案

查看这个来自堆栈溢出的线程:

您可以在命令行中执行如下操作:

You can do it in the command line as follows:

schtasks/Create/SC HOURLY/TN PythonTask/TR "PATH_TO_PYTHON_EXE PATH_TO_PYTHON_SCRIPT"

这将创建一个名为PythonTask"的每小时任务.您可以将 HOURLY 替换为 DAILY、WEEKLY 等.PATH_TO_PYTHON_EXE 将类似于:C:\python25\python.exe.通过在命令行中编写此内容来查看更多示例:

That will create an hourly task called 'PythonTask'. You can replace HOURLY with DAILY, WEEKLY etc. PATH_TO_PYTHON_EXE will be something like: C:\python25\python.exe. Check out more examples by writing this in the command line:

schtasks/?

否则,您可以打开任务计划程序并通过 GUI 执行此操作.希望这会有所帮助.

Otherwise you can open the Task Scheduler and do it through the GUI. Hope this helps.

这可能会解决您的问题.

This might solve your problem.

如果它仍然无法工作,您可以参考 来自 esri 的这个线程.这将完成您的工作.

If it is still not working you may refer to this thread from esri. This will get your job done.

这篇关于无法通过 Windows 任务调度程序运行我的 python 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆