0

I have a Python script that will successfully complete when run from the Python window in ArcMap or ArcCatalog, however, when I run as a standalone it will cause python.exe stopped working crash once it completes. I've tried from a command prompt and a couple different IDEs with the same result.

The target files and updates complete before the crash and when I compare the results from the stand alone script to the one run within the Python window they appear identical. I've placed print statements at various locations including on the last line to help with debugging and all of them print. Since the crash is happening after the all lines in the script have been run, I'm not sure how to further debug this. I'm running ArcGIS 10.5.1.

If I comment out the arcpy.CreateRapidGraphic line then the crash does not occur.

I'm primarily running via a command prompt

C:\Python27\ArcGIS10.5\python.exe D:\Projects\py\createmap.py

but have also tried double-clicking and running in visual studio code.

The last lines of my code are similar to this:

arcpy.CreateRapidGraphic_defense(geodb, areaOfInterestLyr, productType, version, mapDocumentWork, rasterLyr)
print "graphic done"
arcpy.CheckInExtension('defense')
arcpy.CheckInExtension('foundation')
arcpy.CheckInExtension('spatial')
arcpy.CheckInExtension('3D')
print "checkin done"
7
  • 1
    Can you share your script?
    – Stella
    Commented Jul 29, 2019 at 17:04
  • 1
    how are you actually executing the script (e.g. typing the explicit command on the CLI or double-clicking the file?). what in your observation indicates that a crash has occurred?
    – Paul H
    Commented Jul 29, 2019 at 18:26
  • Please use the edit button beneath your question to revise it with any requested clarifications.
    – PolyGeo
    Commented Jul 29, 2019 at 19:19
  • Are you working with a geometric network? If so, I may have seen something similar a few years ago at gis.stackexchange.com/questions/260788/…
    – PolyGeo
    Commented Jul 29, 2019 at 19:24
  • Note that it may not truly be the last lines that are causing a crash, if it's crashing on exit. If it crashes reliably then I'd comment out one call to arcpy at a time until it (hopefully) stops
    – mikewatt
    Commented Jul 29, 2019 at 19:43

2 Answers 2

1

Usually, it is related to the python version that you have installed or specific machine configuration, I had a similar issue with a script that in one machine was working perfectly but on another one, it was crashing. Check if the python IDLE match the one on Arcmap. You can change it on the environment variables on your computer by changing the python paths.

1

After installing ArcGIS you need to take some extra steps. Find directory of /python27 which has been installed when you installed ArcGIS. Then add following directories to global path variable in environment variables:

  1. C:\Python27
  2. C:\Python27\Lib
  3. C:\Python27\Scripts

Then based on IDE you are using, you need to define a python interpreter. If you are using Visual Studio Code as an IDE, you have to install this extension. This link may help you. Another IDE that you can be used is PyCharm. Like Visual Studio Code, again you need a python interpreter. This option can be fine here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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