简体   繁体   English

任务计划程序打开命令提示符但不运行 python 脚本

[英]Task Scheduler opens command prompt but does not run python script

I run a python script from my command prompt once per day, but I want to automate this with task scheduler.我每天从命令提示符运行一次 python 脚本,但我想使用任务计划程序自动执行此操作。 I can only make it open Command Prompt, but I have to then run the python program manually.我只能让它打开命令提示符,但我必须手动运行 python 程序。 What am I missing?我错过了什么?

  1. New Folder myTasks新文件夹 myTasks
  2. Create basic Task创建基本任务
  3. Task name, trigger, start a program任务名称、触发器、启动程序
  4. Program script/ cmd.exe程序脚本cmd.exe
  5. Add Arguments: "C:\Users\Matthew Olive\PycharmProjects\VOLALGO1\scraper.py"添加 Arguments: "C:\Users\Matthew Olive\PycharmProjects\VOLALGO1\scraper.py"
  6. Manually Run Task to test it手动运行任务来测试它

All I get is the command prompt opening up and it displays: C:\WINDOWS\system32>我得到的只是命令提示符打开并显示: C:\WINDOWS\system32>

It wont actually run the python script.它实际上不会运行 python 脚本。 If I type python "C:\Users\Matthew Olive\PycharmProjects\VOLALGO1\scraper.py" after C:\WINDOWS\system32> it will run just fine.如果我在C:\WINDOWS\system32>之后键入python "C:\Users\Matthew Olive\PycharmProjects\VOLALGO1\scraper.py"它将运行得很好。

Instead of using cmd.exe you could directly use the python.exe with the full path to it.您可以直接使用python.exe及其完整路径,而不是使用cmd.exe An example location of where it might be is它可能在哪里的一个示例位置是

C:\Users\MyName\AppData\Local\Programs\Python\Python37-32\python.exe

Thanks CaffeinatedCoder!感谢 CaffeinatedCoder! I figured it out!我想到了!

I used exactly that for the program/script and it worked.我完全将它用于程序/脚本并且它有效。 Turns out it was running in the python terminal, but it would disappear immediately, so I added input("Press Enter to Exit...") to the end of the python script.结果它在 python 终端中运行,但它会立即消失,所以我在 python 脚本的末尾添加了input("Press Enter to Exit...")

暂无
暂无

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

相关问题 任务调度程序运行我的 python 脚本,但它什么也不做 - Task scheduler run my python script but it does nothing 我的 Python 脚本无法从任务计划程序运行 - My Python Script does not run from Task Scheduler Python 脚本不会从 .bat 文件、任务计划程序或 cmd 提示符运行 - Python script won't run from .bat file, Task Scheduler, or cmd prompt 运行 Python 脚本时命令提示符打开和关闭 - Command Prompt Opens and Closes When Running Python Script 能够通过IDE,命令行运行Python3脚本,但不能通过双击或任务计划程序运行 - Able to run Python3 Script through IDE, Command Line, but not by double clicking or Task Scheduler 脚本无法像在PyScripter中那样在命令提示符下运行 - Script does not run on command prompt as in PyScripter 为什么Windows 10 Task Scheduler执行我的Python脚本时会产生不同的运行 - Why does my Python script run differently when executed by Windows 10 Task Scheduler Python 脚本不会在任务计划程序中运行“无论用户是否登录都运行” - Python script will not run in Task Scheduler for "Run whether use is logged on or not" 使用python脚本在命令提示符下运行命令 - Run commands in command prompt using python script 为什么 python 脚本在 pycharm 中运行和在命令提示符下运行时的行为不同? - Why does a python script behaves differently when it is run in pycharm and when it is run from a command prompt?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM