Select to view content in your preferred language

Python crashes when trying to run arcpy.ListRasters

2376
10
11-22-2017 07:54 AM
AlexTurner4
Emerging Contributor

I have a Python script that I have been using for the past year but I recently updated my computer to Windows 10 and now Python is crashing when trying to run the script. I was able to isolate the crash to line 4 below where I am trying to list the rasters from my input folder. 

The inputFldr variable is a user input from a Tkinter GUI I created for this script. The only thing that happens before this section of code is receiving the various user inputs from the Tkinter GUI and assigning them to variables, as well as creating a few output folders. All of this happens with no problem and then Python crashes when trying to execute the red line. I am using Python 2.7.13 and ArcGIS Desktop 10.5.1

Anyone have an idea why this is happening? I am lost. Even did a try/except around line 4 and Python still crashed

sr = arcpy.SpatialReference(4326)
arcpy.env.workspace = inputFldr
arcpy.env.outputCoordinateSystem = sr
rasters = arcpy.ListRasters()‍‍‍‍
0 Kudos
10 Replies
AlexTurner4
Emerging Contributor

In case it helps anyone else, I was able to finally get my script to run again successfully. I moved the import line shown below from the beginning of my script to right before I actually utilize ogr in the script, which is after the ListRasters line. I just happened to stumble upon this solution while rebuilding the script. No idea why it works by moving that line, but it does. Thanks for all the suggestions

from osgeo import ogr 
0 Kudos