# Geocodeing in Python batch failing

739
8
06-27-2017 09:04 AM
New Contributor III

So I ran the 'Geocode Address' tool in ArcMap and it ran fine geocoding some addresses in an excel spreadsheet. I then went to 'Geoprocessing' and then 'Results' and did a 'Copy as python snippet'. I then placed the code in the 'Python' window that can be launched from the 'Geoprocessing' menu of ArcMap, I added the needed Import and Environment information to the Python window and ran the process, which also ran fine and geocoded my addresses. However, when I include the exact same code in a file with a '.py' suffix and try to run it, it fails every time with a message of "python.exe has stopped working - A problem caused the program to stop working correctly. Please close the program."

The code I am trying to run looks like the following:

# Import system modules
import arcpy
from arcpy import env
env.workspace = "C:\Users\A_eric.anderson\Documents\ArcGIS\Default.gdb"

Any insight on what the problem might be, would be greatly appreciated.

Thanks!

- Eric -

1 Solution

Accepted Solutions
New Contributor III

Hi there Arjun,

Unfortunately, first level support wasn't able to fix my problem, but through their help, they un-intentionally pointed me in the right direction for an alternative. I was trying to process a large (30,000 row) excel spreadsheet. It worked fine in ArcMap, as well as ArcPy being run from ArcMap. However, when I tried to run it through the command prompt, it failed. What I eventually figured out was that if I converted my Excel spreadsheet to a CSV file, the python script would run fine from the command line.

I tried to express to first level support that the developers should look into this, but she seemed to indicate that there was a slim chance of that happening. I don't know if this information will help you or not in your efforts, but I wanted to give you an update on what I found out.

Best wishes! - Eric-

8 Replies
Esteemed Contributor

What version of ArcGIS are you running?

Are you executing the py script in a Windows Scheduled Task?

New Contributor III

We are running ArcGIS version 10.5.

As far as execution is concerned, I was running the '.py' file by executing it through the dos command by calling the '.py' file.

Thanks for any insight you may be able to provide where I may have gone off track!

- Eric -

Esri Frequent Contributor

Some other thoughts:

What version of Python are you running it in outside of ArcMap?  You can add:

import sys
print(sys.version)‍‍

You can run this in ArcMap to make sure the versions are the same, (assuming you're not using the version included with the installation of ArcMap).

The in_table parameter seems funny...

Should it have two extensions?

Can you run a simple buffer to see if that goes through?  Perhaps you can isolate it to the Geocode Addresses tool.

New Contributor III

According to the Print command you suggested, we are running version 2.7.12 of Python.

The end goal will be to get this to run from Scheduler, but I wanted to try to slug my way through any problems using the DOS command first.

Thank you all for your help in finding what the problem might be.

- Eric -

New Contributor III

I ran a Buffer process, in ArcMap, obtained the Python snippet in the same way, posted it to my python script and ran that. The results of the Buffer using Python under the DOS prompt worked just fine.

I changed the name of my Excel spreadsheet to remove the extra '.xlsx' from it and then also change the file name in the python script. The end result of that test was a failure of the same type that I had initially. It sounds like the issue has to do with Geocoding at this point.

Any additional insight would be greatly appreciated.

Thank you! - Eric-

Occasional Contributor

Any solution to this problem? I have been having a problem with the geocoding tool not accepting the path for the locator when run in a scheduled task. The locator sits in a folder on a mapped network drive, the rest of the data is on the local C drive. So my setup is similar to yours. The script runs as expected when running from cmd or within IDLE, but not as a scheduled task. Any thoughts on how to move forward would be appreciated.

New Contributor III

Hi there Arjun,

Unfortunately, first level support wasn't able to fix my problem, but through their help, they un-intentionally pointed me in the right direction for an alternative. I was trying to process a large (30,000 row) excel spreadsheet. It worked fine in ArcMap, as well as ArcPy being run from ArcMap. However, when I tried to run it through the command prompt, it failed. What I eventually figured out was that if I converted my Excel spreadsheet to a CSV file, the python script would run fine from the command line.

I tried to express to first level support that the developers should look into this, but she seemed to indicate that there was a slim chance of that happening. I don't know if this information will help you or not in your efforts, but I wanted to give you an update on what I found out.

Best wishes! - Eric-

Occasional Contributor

So for whatever reason, the geocoding function did not like my mapped path to the locator (like c:\path\to\locator). I ended up using the server name itself (r\\servername\path\to\folder) and that did the trick. Not sure why the geocoding tool is so finicky.