<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcPy ListDataFrames on empty MXD crash in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299078#M23160</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you applied service pack 1?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't have a copy without SP1 to test, but, with 10.1, service pack 1 on an empty mxd OR an mxd with all the data sources broken, I can run both these commands without error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tried it on two different computers, works just fine in both.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Aug 2013 16:33:41 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2013-08-01T16:33:41Z</dc:date>
    <item>
      <title>ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299072#M23154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a script that iterates through multiple directories and runs a report on mxd information. Running into problems with it however whenever an empty mxd is loaded.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Whenever running " DFList = arcpy.mapping.ListDataFrames(mxd)" I get a crash of the python script .&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any way to test for an empty mxd or perhaps some other problem that i'm missing here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew L.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2012 16:27:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299072#M23154</guid>
      <dc:creator>AndrewLaux</dc:creator>
      <dc:date>2012-05-29T16:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299073#M23155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Even an empty mxd should have a dataframe. The line as you show it runs for me without crashing. Are you sure something else isn't going on? A layer index reference maybe?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2012 18:14:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299073#M23155</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-05-29T18:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299074#M23156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Maybe you need to check what the 'mxd' variable contains!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 10:55:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299074#M23156</guid>
      <dc:creator>HugoAhlenius</dc:creator>
      <dc:date>2012-05-30T10:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299075#M23157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please show us the error message and a little more code (using the CODE-Tags).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It would be easier to understand the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Often print (or AddMessage) helps. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.AddMessage(mxd)
DFList = arcpy.mapping.ListDataFrames(mxd)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:21:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299075#M23157</guid>
      <dc:creator>FabianBlau</dc:creator>
      <dc:date>2021-12-11T14:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299076#M23158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would suggest using a "try/except" statement in python. I wasn't able to duplicate your crash, but if you're just getting a error message, this will probably work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;mxd = arcpy.mapping.MapDocument("C:\\MappingStuff\\Untitled.mxd")
try:
 DFList = arcpy.mapping.ListDataFrames(mxd)
except:
 print "The MXD at "+mxd.filePath+" is empty or layers could not be listed."
 arcpy.AddMessage("The MXD at "+mxd.filePath+" is empty or layers could not be listed.")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:21:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299076#M23158</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2021-12-11T14:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299077#M23159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am having this same problem with ArcGIS 10.1 and Python 2.7.&amp;nbsp; Doing a arcpy.mapping.ListDataFrames will crash python if the mxd is either empty or all of the layers inside the data frame are broken.&amp;nbsp; A try/except block does not catch this error.&amp;nbsp; I get a IDLE window RESTART when this happens in while running a script.&amp;nbsp; Trying to acces the activeDataFrame property of the map document will also crash python.&amp;nbsp; The method arcpy.mapping.ListBrokenDataSources() also crashes when all of the data sources are broken.&amp;nbsp; I can open the file in ArcMap 10.1 to see that all of the data sources are broken.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;**Update&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The command does work inside of command line window started from ArcCatalog 10.1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 14:50:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299077#M23159</guid>
      <dc:creator>David_JAnderson</dc:creator>
      <dc:date>2013-08-01T14:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299078#M23160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you applied service pack 1?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't have a copy without SP1 to test, but, with 10.1, service pack 1 on an empty mxd OR an mxd with all the data sources broken, I can run both these commands without error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tried it on two different computers, works just fine in both.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 16:33:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299078#M23160</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-08-01T16:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299079#M23161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have applied service pack 1.&amp;nbsp; I also tested again a ArcGIS 10.0 w/ sp 4.&amp;nbsp; Where I get the same results.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you use an IDLE/Pythonwin to test from or a command line from Arcmap/catalog.&amp;nbsp; I have determined that the problem only occurs when running from a stand alone python window.&amp;nbsp; It works fine from a arcmap/catalog command line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is not the first time I have encountered an issue where something fails in an external python window but works inside of arc.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 17:21:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299079#M23161</guid>
      <dc:creator>David_JAnderson</dc:creator>
      <dc:date>2013-08-01T17:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299080#M23162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I do everything in the stand alone IDLE that comes with the default install.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
&amp;gt;&amp;gt;&amp;gt; doc = r"D:\test.mxd"
&amp;gt;&amp;gt;&amp;gt; import arcpy
&amp;gt;&amp;gt;&amp;gt; mxd = arcpy.mapping.MapDocument(doc)
&amp;gt;&amp;gt;&amp;gt; DFList = arcpy.mapping.ListDataFrames(mxd)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ### first with just empty mxd
&amp;gt;&amp;gt;&amp;gt; del mxd
&amp;gt;&amp;gt;&amp;gt; mxd = arcpy.mapping.MapDocument(doc)
&amp;gt;&amp;gt;&amp;gt; DFList = arcpy.mapping.ListDataFrames(mxd)
&amp;gt;&amp;gt;&amp;gt; arcpy.mapping.ListBrokenDataSources(mxd)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ### then added windrosepoints, deleted the dataset, ensured it was broken, this is result.
[&amp;lt;map layer u'windrosepoints'&amp;gt;]
 &lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Only tested with empty and with ONE broken dataset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This is not the first time I have encountered an issue where something fails in an external python window but works inside of arc. &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have found just the opposite of this.&amp;nbsp; That is why I run everything externally.....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:21:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299080#M23162</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-11T14:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299081#M23163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried that test of creating a mxd then breaking the data source.&amp;nbsp; The listdataframes does work.&amp;nbsp; Perhaps a salient fact is that the mxd that I am trying to work with is rather old, version 8.1 I believe.&amp;nbsp; Which is why I am working with it as I know it is broken because the file system has changed since those days.&amp;nbsp; I'm trying to figure out how bad the problem is which is one of the reasons for the script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 18:22:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299081#M23163</guid>
      <dc:creator>David_JAnderson</dc:creator>
      <dc:date>2013-08-01T18:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299082#M23164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm, wonder if you open it with the new version, and select "Save a Copy" if it will keep broken paths in there and let you replace?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 18:26:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299082#M23164</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-08-01T18:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299083#M23165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No luck.&amp;nbsp; It crashed again.&amp;nbsp; Plus I learned that the arcpy.mapping.saveACopy methods also fails on this file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For now it looks like I'll just have to screen out the older files for now and try open up a ESRI support ticket to see if they can resolve the problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 19:06:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299083#M23165</guid>
      <dc:creator>David_JAnderson</dc:creator>
      <dc:date>2013-08-01T19:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299084#M23166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I know this is about automating it, but if you right-click on the mxd in ArcCatalog and "change data source" does that crash also?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 19:27:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299084#M23166</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-08-01T19:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy ListDataFrames on empty MXD crash</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299085#M23167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No problem with doing that operation. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I now have an ESRI support ticket that I hope will resolve this problem.&amp;nbsp; Will post when I have results.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Aug 2013 14:43:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-listdataframes-on-empty-mxd-crash/m-p/299085#M23167</guid>
      <dc:creator>David_JAnderson</dc:creator>
      <dc:date>2013-08-02T14:43:49Z</dc:date>
    </item>
  </channel>
</rss>

