Select to view content in your preferred language

ERROR 999999 appears while trying to run a python script using arcpy functionalities through Task Schedular

516
8
Jump to solution
08-01-2024 07:48 AM
Murtaza_Mir
Occasional Contributor

Hi,

I have written a python script that is using arcpy as well. One of the functions that I am using is the arcpy.management.CreateTable. I created a batch file that calls this script. When I run the batch file directly, the script runs fine with no errors but when I use a Task Schedular instead to call the batch file for running the script, I run into the following error:

ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Failed to execute (CreateTable).

The error appears while trying to create the Table. I don't understand what is the cause of this. Any suggestions?

Thank you

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Murtaza_Mir
Occasional Contributor

Hi,

I figured out the actual cause. The licensing issue was happening because I was storing the created table in ScratchGDB. Apparently, this was causing the issue to fail. When I changed the location for the table, the error got fixed. Thank you @MichaelVolz  and @MErikReedAugusta  for pointing me in the right direction.

View solution in original post

8 Replies
MErikReedAugusta
Frequent Contributor

Maybe it could be a licensing issue?  Try setting the scheduled task for a time during the day when you're there and make sure you're logged into both the machine running the script and into ArcPro, then see if it still fails.

I haven't run any task-scheduled scripts yet, myself, but I remember a discussion a while back on one of the GIS communities I follow where someone had a similar problem.  The script was trying to run in the middle of the night, and the machine that was trying to run it wasn't logged into ArcPro at that time of night.  Don't remember if they got a 999999 from it or not, though.

0 Kudos
MichaelVolz
Esteemed Contributor

Does your script fail every time or is it more of a random failure in Task Scheduler?

Check your Event Viewer as that helped me find issues with python scripts.

0 Kudos
Murtaza_Mir
Occasional Contributor

The script fails every time with the Task Scheduler. The script otherwise runs fine when I run the batch file directly. It does not appear to be any issue with any code.

0 Kudos
MichaelVolz
Esteemed Contributor

Are you running Task Scheduler with highest privilege?

0 Kudos
Murtaza_Mir
Occasional Contributor

Yes, the script is running with the highest privilege. Is there a possibility that somehow when the script is run through the scheduler, it does not retain the licenses? I am using a cloned version of base python environment of arcgis pro with a few additional packages, not the base environment itself.

0 Kudos
MichaelVolz
Esteemed Contributor

Can you try creating a simple script just importing arcpy with a print statement before and after the import statement in the standard python environment, that is called from a bat file?

This is what I needed to do at my org to determine that anti-virus software was interfering with running a python script thru Task Scheduler even though it ran fine when just running directly from the bat file.

0 Kudos
Murtaza_Mir
Occasional Contributor

Hi,

I figured out the actual cause. The licensing issue was happening because I was storing the created table in ScratchGDB. Apparently, this was causing the issue to fail. When I changed the location for the table, the error got fixed. Thank you @MichaelVolz  and @MErikReedAugusta  for pointing me in the right direction.

Murtaza_Mir
Occasional Contributor

It may be a licensing issue although I wonder how does the batch file directly runs successfully. I will try that as well. Thank you for the suggestion.