Select to view content in your preferred language

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

5350
8
11-04-2019 08:04 AM
ScottStopyak
Frequent Contributor

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

8 Replies
RobertBorchert
Honored Contributor

Geo-event processor

0 Kudos
ScottStopyak
Frequent Contributor

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 Emeritus

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
Frequent Contributor

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.

RaquelBensadoun
Occasional Contributor

Following and hoping someone responds to you soon, we are having the same issue where the script runs in Jupyter but not as a standalone .py.

0 Kudos
KimOllivier
Honored Contributor

What you have to do is add in the arcgis module as well as arcpy. Then you can access AGOL tools which include the Geocoding Service. Or switch to the geocoding service direct from ArcGISPro. Thefunctions and  parameters are different but it is the same service ultimately, and will also cost credits.

0 Kudos