I have several standalone scripts that create a list of shapefiles to process (or coverages in one of the scripts). Sometimes my script crashes after it processes three files, sometimes ten, sometimes with just one to go. In some cases, it's quite complex operations, but sometimes, it's just a simple arcpy.Union_analysis(inShp, outShp) or with CalculateField_management().

It seems totally random because I just delete the outputs before restarting my scripts and it may or may not work the next time. Eventually it works, sometimes on the first try, but other times, I could have to retry it 2 or 5 or 10 times.

Any ideas what could cause this? Should I clean or delete something from memory that could cause a crash?


  • 3
    Could you provide a Python script sample that is causing you problems? – Aaron Aug 9 '12 at 18:46
  • 1
    You could add a try/except handler to give you more information on the error. See the Python Errors and Exceptions section – Stephen Lead Aug 10 '12 at 3:24
  • Here's some: This one batch convert .e00 into shp in structured directories. That one takes several points (users/train stations) and create a "service area" from a certain point density and the last one compares each service area to the others to determine overlaps. They never crashes at the same place or with the same tool (Dissolve, Select, ...). Thanks! – fgcartographix Aug 10 '12 at 13:32
  • It's maddening... I added Errors/Exceptions Handling (with the traceback module to get python and ArcPy message). I simply put all my code inside my loop in the "try:" and my loop increment as well. When there's a error, my counter don't increment because the "i=i+1" is after when the error occured. So, when the loop restart, my "i" is the same as previous and it restart processing the same files that cause the error... And then it works! See this screenshot, Green, first try, yellow, 2nd and blue, ok and processing the next... – fgcartographix Aug 10 '12 at 15:21
  • Could that be that the script is too quick and arcpy outputs necessary for the next step arent already available? Clearly the code itself isn't a problem? Maybe adding a "time.sleep(1)" could help? – fgcartographix Aug 10 '12 at 15:23

Are you creating any featureclasses in memory? Because the inconsistency could be down to not deleting an in-memory fc. If you are, try something like:

    if arcpy.Exists(fc):
        del fc

after each iteration of your loop. Hope this helps!

  • You'd likely need to use arcpy.Delete_management() as opposed to del – Roy Nov 16 '12 at 19:50
  • I used Delete_management() for the output of all tool that create another file as output and del for "in_memory" datasets. The two tools that cause much problem are "arcpy.FeatureClassToShapefile_conversion(inFeaturePolygon, outFolder)" and "arcpy.Project_management(inFeatureClassPolygon, outFeatureClassPolygon, outCoordSys)". The thing is that since it's looping, the values of my variables are reassigned each time... Of course, if "Foncier Quebec" (Quebec Land Parcels) could just give us anything except .e00... – fgcartographix Nov 19 '12 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.