[英]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?
我错过了什么?
cmd.exe
cmd.exe
"C:\Users\Matthew Olive\PycharmProjects\VOLALGO1\scraper.py"
"C:\Users\Matthew Olive\PycharmProjects\VOLALGO1\scraper.py"
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.