Script crashes python but works in Model Builder

1127
5
11-25-2013 12:55 PM
CassidyKillian
Occasional Contributor II
I recently upgraded to 10.1 SP1.  The attached script works as a model in model builder but when I try to run it as a stand alone script or scheduled task it crashes python. 

The code is exactly how it comes out of model builder with the overwrite option added.
Tags (2)
0 Kudos
5 Replies
StacyRendall1
Occasional Contributor III
Can't see anything obviously wrong with it. Are you running it from the command line, or within ArcMap as a python tool? Does it spit out any information, or just crash?

I have tidied it up (Model Builder produces pretty awful code), can you run it now and tell me if it fails too?

I also added an arcpy.AddMessage() which will tell you the current test it is running, so you can establish if it is one particular test that is causing the problem...
0 Kudos
CassidyKillian
Occasional Contributor II
Stacy,
Thanks for the help, but still no luck.  I have tried running the script everywhere and python crashes every time.  It always just gives me the standard "python.exe has stopped working" error and closes the program.

Im not sure if there are error log files anywhere that will give me any information.  I am at a dead end.
0 Kudos
StacyRendall1
Occasional Contributor III
Updated so it will now write a file to c:\CrimeMap_output.txt. It will add a description for each test before running it and note when each test is complete. You can change the file location by modifying the outTxtFile variable in the code.

Please explain exactly how you are running the code.
0 Kudos
CassidyKillian
Occasional Contributor II
Still no luck.
To run the script I have tried to run it in IDLE, double click on script, right click ->Open with, etc....
The command prompt is running as C:\Python27\ArcGIS10.1\python.exe

The text file had one line that reads "Crime Map code output"
0 Kudos
StacyRendall1
Occasional Contributor III
The problem is with the composite locator! For some reason they work from Model Builder but fail from Python scripts, here is a previous forum post regarding this:
http://forums.arcgis.com/threads/81528-Python-crashes-running-stand-alone-script-composite-locator-A...

I forgot about that until your last post, which allowed me to isolate where the error is occurring (before any of the tests can even start).

You have three options:

  1. get hold of a different ArcGIS version; seems to be OK in 10.2 SP1

  2. make your process not require a composite locator, by doing a series of individual locators, each time selecting addresses that haven't been geocoded (into a feature layer)

  3. use the Parallelised Composite Geocoding script I developed (posted here), which will do the same thing as a composite locator but can make use of multiple CPUs


I am happy to help out if you want to do number three - it would be good for it to have some testing! The green comment section at the top of the code should explain all the inputs required. If you download the script you can then add it as an import at the top of your script and call it.
0 Kudos