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()
Have you tried to add a wildcard value?
rasters = arcpy.ListRasters('*')
http://pro.arcgis.com/en/pro-app/arcpy/functions/listrasters.htm
Yes, actually my original code was rasters = arcpy.ListRasters('*', 'ALL') and it also crashed
I have no way of knowing for sure, but your Tkinter GUI is likely part of the problem. You'll have to research how to successfully implement that, but from what I've read it doesn't play nicely in ArcGIS.
You may want to switch gears and build an Add-In or just get creative with building a Toolbox for your GUI instead.
Yeah, I was hoping to avoid building another tool to run this but I may have to. The Windows 10 upgrade was not my choice and this isn't the only problem with ArcGIS tools I've had since. Bummer cause this tool ran much faster using Tkinter than within Arc.
You should probably look for specific reasons why you think it runs slower and validate via testing. I wouldn't just dismiss a GP toolbox as the reason.
Alex:
Sorry for high-jacking this thread, but can you list the other problems you've had with Windows 10 and ArcGIS tools. My org is still at Windows 7, but we should be moving to Win10 in early 2018 as an enterprise. I would appreciate the knowledge and it might help other GeoNet users.
I can't say for sure that Windows 10 is the culprit (correlation not equal to causation) but the main problems I have been having are working with rasters via Python Scripts. I have another script that crashes on a line where I am running the Raster calculator. Always worked with no problem until the Windows 10 upgrade. Although the actual Raster Calculator tool in ArcMap works for me, it always crashes when using Python. That is the only other specific problem I can think of right now that I noticed after upgrading. I had to reinstall ArcGIS and all my Python modules after the upgrade so something could have gone wrong there as well.
are you getting an empty list returned (e.g. [ ] ) or an error?
If just an empty set, print out the valid of you inputFldr to make sure 1) it is valid (do this in the program, before the point it crashes), and 2) that it contains rasters (set up the Python window with the same env.workspace and check it..
I am testing on a window 7 machine, so if it is a win10 issue, I have no way to test.
I don't get an error of any kind. Python just crashes. I also printed out the valid of inputFldr and confirmed that everything is alright there, even copied it and used in ArcMap Python window. The ListRasters() command worked within ArcMap so I am assuming it is something with the Tkinter GUI and/or Windows 10