How do I run a jupyter notebook as a scheduled task?

2611
6
11-04-2019 08:04 AM
ScottStopyak
Occasional Contributor II

I want to run notebooks from the default ArcGIS Pro 2.4.2 conda environment as scheduled tasks. How do I do this?

6 Replies
RobertBorchert
Frequent Contributor III

Geo-event processor

0 Kudos
ScottStopyak
Occasional Contributor II

You can run them directly if you have geo-event processor extension? We'd kicked around the idea of getting that for some other workflows but couldn't quite justify the price tag. If it does run notebooks directly and in automation, it makes for a stronger case to purchase it.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Hey Scott,

You can export your notebook to a .py file by going to File > Download As > Python (.py).  You can then use ArcGIS Pro's python environment (C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3) to execute the python file. 

The following article will walk you through how to set up Task Scheduler.  For the program/script portion, you will use C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe instead of C:Python27ArcGIS10.2python.exe.

JoeBorgione
MVP Esteemed Contributor

There is also the option to call it from a .bat file:  Run stand-alone scripts—ArcPy Get Started | ArcGIS Desktop 

That should just about do it....
ScottStopyak
Occasional Contributor II

Thanks. We've been running bats to call .py scripts for several years and it works ok. I was just wanting to migrate those python scripts to jupyter and develop new ones in jupyter because there are some nice advantages to doing it that way. So I'm looking for a way to run them directly using nbconvert or similar without exporting.

JaredPilbeam2
MVP Regular Contributor

Any success running a *.ipynb  from the Task Scheduler? I would also like to run a Notebook file directly. This particular script I have saved as a .py file produces errors caused by the ArcGIS World Geocoding Service. And for some reason it only runs as a Notebook file.