Arcpy functions that output tables fail when running from a batch file

1733
5
Jump to solution
12-22-2016 07:25 AM
DanielInterrante
New Contributor II

Hello,

I'm having an issue trying to automate a python script that relies heavily on arcpy/ArcGIS.  I have a functioning version of the script that runs perfectly in the ArcMap Python module, that continually fails when trying to translate it to something what will run from a batch file.   I'm trying to set it up so that Windows Task Scheduler can grab it. What I've come to notice is that any function that has a table as an output (Table to Table, Copy Rows, Frequency Count, ect) fails when running from the batch.  I've been copying and pasting these directly into the desktop version with 100% success so it doesn't seem like there are typos.  Has anyone ever run into this before?  Or is there a way to automate the script to run in ArcMap rather than python.exe?  I'm working on Windows Server 2012 R2.  Thank you!

0 Kudos
1 Solution

Accepted Solutions
DanielInterrante
New Contributor II

Hi James,

It looks like there was a lock that was screwing things up.  I had an ArcMap window open for troubleshooting and I guess that prevented tables from functioning properly.  For whatever reason spatial feature classes were unaffected.  Than you for your help!

View solution in original post

5 Replies
JamesCrandall
MVP Frequent Contributor

What does your .cmd or .bat file look like?

What does the error say exactly when executed from the batchfile?  (you should have some sort of logging in order to capture these types of things).

0 Kudos
DanielInterrante
New Contributor II

Hi James,

As for my batch file all I have is : "start C:\Python27\ArcGIS10.4\python.exe E:\Script_Folder\Script_File.py"

I have logging set up with print statements before and after the line where its happening (right now I'm stuck on the Frequency Analysis).  I always get the print statement right before the function then it fails.  Are there more specific types of log functions that would be more helpful to use in this situation?

0 Kudos
DanielInterrante
New Contributor II

I have this line in a Try/Except function, so I always get the fail error I have in the "Except" section

0 Kudos
JamesCrandall
MVP Frequent Contributor

I think if you right-click the batch file and run as admin it should print out the execution and any errors.  Perhaps remove any try/except blocks and just let the error print out in the command window to see if you can get an actual error number to show.

0 Kudos
DanielInterrante
New Contributor II

Hi James,

It looks like there was a lock that was screwing things up.  I had an ArcMap window open for troubleshooting and I guess that prevented tables from functioning properly.  For whatever reason spatial feature classes were unaffected.  Than you for your help!