Python script as sheduled task (ArcGIS Pro)

09-14-2018 06:34 AM
New Contributor III

Is anyone able to run a script through Windows Task scheduler using ArcGIS Pro?  As a test I have an extremely simple script (just copying a feature) that runs fine within ArcGIS Pro.  

import arcpy"C:\CityScripts\ScheduledTasks\SafewatchCameras\Data\General.gdb\SafewatchCameras", "C:\CityScripts\ScheduledTasks\SafewatchCameras\Data\General.gdb\SafewatchCamerastemp2", None, None, None, None)‍‍

I setup the Task Scheduler as recommended by the ArcGIS Pro help and while the Task completes successfully nothing happens with the script.

Put in a call to ESRI tech support but they said it was a Windows issue and therefore couldn't work on it.


31 Replies
New Contributor II


We were having issues running arcpy or arcgis modules on task scheduler on our 2016 windows server. It would error out because the script was running under the SYSTEM account and was not able to log into AGOL for the license. We tried to manually install Pro and switching to a single use license but this failed as well. Even when manually installing Pro and switching the license it did not work because the license install manager is installed in the user profile.

We finally found the answer!

We had to run cmd line install Pro with it pointing at a single use license. We have to run a command install to a place accessible by the SYSTEM account. This cleared up everything. 

Tracy Wamsley

0 Kudos
New Contributor III

Here's another addition to the thread in case it's helpful to others since this took me awhile to sort out scheduled tasks using ArcGIS Pro's Python 3 environment.


  • Windows Server 2016 Datacenter
  • ArcGIS Pro 2.5.1
    • Concurrent-use licensing 
    • "Authorize ArcGIS Pro to Work Offline" is not checked. 
    • Not signed into either AGOL or Portal (for sake of testing)
    • Python version 3.6.9
  • ArcMap 10.7.1 
    • Concurrent-use licensing 
    • Python version 2.7.16

*Yes, this particular server has both Pro and ArcMap and therefore Python3 and Python2, but only Python3 was set into system's path variable.

Our Python 3 scripts worked correctly from both the command prompt or running them directly from an IDE, yet Windows task scheduler kept reporting an error was returned in the last run result: (0x1). 

Reason for Error:
Windows task scheduler defaulted to running Python 2, causing scripts using Python 3 to fail. It took me awhile to catch this since only Python3 has been set inside the Environment's path variable, so I assumed that Windows Task scheduler would be running Python3 --- not Python2.

(*** not sure about the message about the environment not being activated. ***)

Helper diagnosing script:

I created a dummy script using only Python 2 and used the sys module to report which version of Python was being called when the script was run through Task scheduler. The script revealed it was Python2, cementing that I needed to explicitly point to Python 3 installation.

import os
import sys
from datetime import datetime

def main():
      basepath = os.path.dirname(__file__)
      os.chdir(os.path.join(basepath, 'Test_script'))
      with open("log.txt", "a") as f:
         f.write('hello world! @ {}\n'.format(
         f.write('Python installation info:\n')

         f.write('major: {} minor: {} micro: {}\n'.format(sys.version_info[0], sys.version_info[1], sys.version_info[2]))
   except Exception as exc:

if __name__ == '__main__':

I had to specify the path to Python3 for program/script and the fullpath to the script as an argument. Again, since my Python2 scripts just worked when I specified the path to the script (done on a different server with Python2 installation set in path), I thought it would work be the same for Python3.    

Python 3 Script (Server with python3 in path and without python2 in path)


Python 2 Script  (DIFFERENT Server with python2 in path and without python3 in path)