Unable to run my python script through windows tas

2019-07-18 09:42发布

I have installed the anaconda package and been running python notebooks and python scripts easily directly from console. I created a script and want it to run every day at particular time period but it did not work. So I created a simple test file to check what is wrong. This is my test file

print("enter the no to exit")
input()

When I run this program on command prompt it ask me for an input and then it exit.

I followed this tutorial to run this program daily using windows scheduler https://blogs.esri.com/esri/arcgis/2013/07/30/scheduling-a-scrip/

In action tab I wrote this

"C:\Anaconda3\python.exe"

And the argument as

"E:\test.py"

And when I run the task manually a black window pop up and automatically closed, I cannot figure out what is wrong. I see it say something like invalid directory. I don't know what am I doing wrong. Please help.

2条回答
闹够了就滚
2楼-- · 2019-07-18 09:58

Have a look into this thread from stack overflow:

You can do it in the command line as follows:

schtasks /Create /SC HOURLY /TN PythonTask /TR "PATH_TO_PYTHON_EXE PATH_TO_PYTHON_SCRIPT"

That will create an hourly task called 'PythonTask'. You can replace HOURLY with DAILY, WEEKLY etc. PATH_TO_PYTHON_EXE will be something like: C:\python25\python.exe. Check out more examples by writing this in the command line:

schtasks /?

Otherwise you can open the Task Scheduler and do it through the GUI. Hope this helps.

This might solve your problem.

If it is still not working you may refer to this thread from esri. This will get your job done.

查看更多
爷、活的狠高调
3楼-- · 2019-07-18 10:03

To run Python programs in Task Manager on Windows: In "Programs/Script" input path to python.exe In "Add Arguments"input script file name In "Additional Information" input path to location where file is saved

For example:

Path to Python: C:\Users\your_user_name\AppData\Local\Programs\Python\Python36-32\Python.exe

Script name ./script.py

Path to location where script is saved: C:/foldername/

查看更多
登录 后发表回答