mnakleh

Python Crashes on Call to ListLayers in Data-Driven Pages

Discussion created by mnakleh on Sep 4, 2012
Latest reply on Feb 8, 2015 by alberto.nieto.cof
Hello!

I've created a script to crawl through all the MXD's on our server and log in a CSV the workspaces being used by each MXD.
The script seems to work fine; the thing is, certain MXD's seem to cause Python itself to crash. No error messages, or codes, just "Python.exe has stopped working."

After tinkering a bit, I found that it seems to be my call to ListLayers that kills everything.
The relevant bit of code is here:

mxd = arcpy.mapping.MapDocument(mxd_file)
wss = [lyr.workspacePath for lyr in arcpy.mapping.ListLayers(mxd)
       if lyr.supports('workspacePath')]


Bizarrely, I can't seem to figure out what's causing Python to crash. The script only seems to fail when it encounters some (but not all) Index Layers for Data Driven Pages...

Even more bizarrely, when the implicated MXD is opened in ArcMap and the script is run in parallel, everything works swimmingly.

Anyone have any clues on what might be going on? I'm using Python 2.6 with an ArcView 10.0 License, SP4. Windows 7, SP 1 64bit.

Thanks a bunch!

Outcomes