[英]0x1 error on python script execution from Task Scheduler (Windows 10)
I am trying to run script ( script1.py
) from windows task scheduler
.我正在尝试从windows task scheduler
运行脚本 ( script1.py
)。 The script is supposed to control Chrome webdriver
and I believe it could be the root of the problem.该脚本应该控制 Chrome webdriver
,我相信它可能是问题的根源。
Result is 0x1.结果是 0x1。
Before creating the task I tested the execution of script1.py
directly from cmd
and it works.在创建任务之前,我直接从cmd
测试了script1.py
的执行并且它工作正常。
So I've created script which writes into the file in the same location as script1.py
, than created task - 0x0
, record is added to the file.所以我创建了脚本,该脚本在与script1.py
相同的位置写入文件,而不是创建任务 - 0x0
,记录被添加到文件中。
works:作品:
<Exec>
<Command>C:\Windows\System32\cmd.exe</Command>
<Arguments>/c C:\Users\MyUser\Anaconda3\python.exe d:\folder\write_dummy_file.py</Arguments>
</Exec>
Doesn't work:不起作用:
<Exec>
<Command>C:\Windows\System32\cmd.exe</Command>
<Arguments>/c C:\Users\MyUser\Anaconda3\python.exe d:\folder\script1.py</Arguments>
</Exec>
The task to run write_dummy_file.py
was created from xml
file of the task to run script1.py
.运行write_dummy_file.py
的任务是从运行script1.py
的任务的xml
文件中创建的。
Those are modules used in the problem script1这些是问题脚本中使用的模块1
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from datetime import datetime
import time
import win32com.client as comclt
import pickledb
Update 1:更新 1:
Apparently I was sleepy when asked this.当被问到这个时,显然我很困。 In the logs I see "Action started", "Action completed", "Task completed".在日志中,我看到“操作已开始”、“操作已完成”、“任务已完成”。 In the Task Manager I can see multiple instances of the Chromedriver, but expected job is not done - browser was never opened在任务管理器中,我可以看到 Chromedriver 的多个实例,但没有完成预期的工作 - 浏览器从未打开
Since we deal with webdriver in the script, the execution should be visible.由于我们在脚本中处理 webdriver,因此执行应该是可见的。 Task has to be set for " Run only when user is logged in ", otherwise it ran in background and failed (it was set to "Run whether user is logged on or not").任务必须设置为“仅在用户登录时运行”,否则它会在后台运行并失败(它被设置为“无论用户是否登录都运行”)。
I had the same problem, but I searched all kinds of ways on Google that were unsuccessful.我也遇到了同样的问题,但是我在谷歌上搜索了各种方法都没有成功。 Finally, I found that the reason for the execution failure was that my py script had a third-party library that was not installed in Python (the script worked well in spyder, but "DLL load failed" in python.exe)hoping to help people in similar situations最后发现执行失败的原因是我的py脚本有第三方库没有安装在Python中(脚本在spyder中运行良好,但是python.exe中“DLL加载失败”)希望能帮到你处于类似情况的人
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.