简体   繁体   English

python脚本在调度程序下无法正常工作

[英]python script doesn't work properly under scheduler

I have a program on Windows Server 2012 that: -reads sql query from text file in the same location -imports helper functions from file in the same location -executes query on sql server (in the same network) and saves the results -creates a google spreadsheet from the results (using API credencials that are in the same location) 我在Windows Server 2012上有一个程序:-从相同位置的文本文件中读取sql查询-从相同位置的文件中导入辅助函数-在sql服务器(相同的网络)中执行查询并保存结果-创建一个结果中的google电子表格(使用位于相同位置的API凭证)

When I log in to tthe server and execute the file in cmd: python myscript.py everything is fine. 当我登录到服务器并在cmd:python myscript.py中执行文件时,一切都很好。 However when I try to do the same from Task Scheduler it fails. 但是,当我尝试从任务计划程序执行相同操作时,它将失败。 I get 0x1 error. 我收到0x1错误。

This is what I put in my Scheduler actions: 这是我在Scheduler动作中所做的:

  • program/script - quoted full path to python.exe (which is in Anaconda folder) 程序/脚本-引用了python.exe的完整路径(在Anaconda文件夹中)
  • Arguments - quoted full path to myscript.py 参数-引用myscript.py的完整路径
  • Start in - blank 开始于-空白

I have tried running it as myself, SYSTEM, Administrators. 我尝试过以我自己,系统,管理员的身份运行它。 Also tried Highest priveleges and user logged on or not options... Also followed another solution on SO that recommended running cmd and then "/c python full/path/to/myscript.py" But it's always the same. 还尝试了最高特权和用户是否登录选项...还遵循另一种解决方案,建议先运行cmd,然后运行“ / c python full / path / to / myscript.py”,但始终相同。

It´s very frustrating. 非常令人沮丧。 I realize it's not strictly coding related issue but I am sure many python programmers had it. 我意识到这并不是严格的编码相关问题,但是我确信许多python程序员都拥有它。

Have you got the same error when starting non-python tasks with scheduler? 使用Scheduler启动非Python任务时遇到相同的错误吗? If not - I would try to install clear Python and create new schedule .bat file with 如果不是,我将尝试安装清除的Python并使用以下命令创建新的Schedule .bat文件

powershell C:\Python27\python.exe C:\Python27\file.py
pause

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM