通过 Windows 调度程序运行 python 脚本不起作用 [英] Running a python script through Windows Scheduler not working

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

问题描述

我正在尝试通过 Windows 任务计划程序自动执行 python 脚本,但它不起作用.在我的 python 脚本的末尾.应该创建两个 CSV 文件,但它们没有.

我尝试了以下方法:1.将我的python.exe地址复制到Program/Script中

<块引用>

C:\Program Files\Python35\python.exe

  1. 在添加参数中,我输入了我的文件名

<块引用>

历史聚合.py

  1. 在开始(可选)中,我输入了我的python脚本的路径

<块引用>

C:\Users\myname\PycharmProjects\Project1

我是不是错过了什么

解决方案

为了简化,我们可以创建一个非常短的 .bat 文件,该文件只会接收运行 Python 脚本所需的命令.

要这样做,试试这个:

在与 Python 文件 (C:\Users\myname\PycharmProjects\Project1) 相同的文件夹中创建一个 executePy.bat 文件,内容为:

@echo off"C:\Program Files\Python35\python.exe" "历史聚合.py"

然后,在您的任务调度程序上,只需使用程序/脚本安排测试:

"C:\Users\myname\PycharmProjects\Project1\executePy.bat"

Add ArgumentsStart In 留空.现在,您的任务应该可以运行了.

I am trying to automate a python script through the Windows Task Scheduler but its not working. At the end of my python script. two CSV files should be created but they arent.

I tried the following: 1. Copied the address of my python.exe to Program/Script.

C:\Program Files\Python35\python.exe

  1. In the Add arguments, i put the name of my file

Historical Aggregation.py

  1. In the Start in (optional), i put the path of my python script

C:\Users\myname\PycharmProjects\Project1

Am I missing something

解决方案

To simplify, we can create a really short .bat file, that will only receive the necessary command to run your python script.

To do so, try this:

Create a executePy.bat file in the same folder than your Python file (C:\Users\myname\PycharmProjects\Project1), with content:

@echo off
"C:\Program Files\Python35\python.exe" "Historical Aggregation.py"

Then, on your task scheduler, simply schedule a test with Program/Script:

"C:\Users\myname\PycharmProjects\Project1\executePy.bat"

Leave Add Arguments and Start In in blank. Now, your task should be ready to run.

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

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