问题描述
我正在尝试通过 Windows 任务计划程序自动执行 python 脚本,但它不起作用.在我的 python 脚本的末尾.应该创建两个 CSV 文件,但它们没有.
我尝试了以下方法:1.将我的python.exe地址复制到Program/Script中
C:\Program Files\Python35\python.exe
- 在添加参数中,我输入了我的文件名
历史聚合.py
- 在开始(可选)中,我输入了我的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 Arguments
和 Start 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.
- In the Add arguments, i put the name of my file
- In the Start in (optional), i put the path of my python script
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 脚本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!