<?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: Runtime error &amp;lt;type 'exceptions.IndexError'&amp;gt;: list index out of range in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/runtime-error-amp-amp-amp-lt-type-exceptions/m-p/543535#M42387</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; What exactly does that error message mean? &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would guess that the error message means the the list from which you're trying to pull the first element ([0]) is empty. I'd check the arguments to your ListLayers function to make sure they are valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The way to know for sure is to put this debug statement right before it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
layers = arcpy.mapping.ListLayers(mxd2,"orange",df2)
print len(layers), str(layers)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 23:32:02 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-12-11T23:32:02Z</dc:date>
    <item>
      <title>Runtime error &amp;amp;amp;lt;type 'exceptions.IndexError'&amp;amp;amp;gt;: list index out of range</title>
      <link>https://community.esri.com/t5/python-questions/runtime-error-amp-amp-amp-lt-type-exceptions/m-p/543533#M42385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am brand new to python coding, trying to figure out how to set up a script to allow me to apply the changes made to the .lyr's in one map to the .lyr's in other maps. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been working my way through the code samples found here: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/UpdateLayer/00s30000003p000000/" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/UpdateLayer/00s30000003p000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Changing just the symbology works fine, but replacing a layer hasn't been.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here's the code, based on the ESRI example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt;&amp;gt;&amp;gt; mxd=arcpy.mapping.MapDocument(r"C:\Users\arc\Desktop\python_tutorial.mxd") &amp;gt;&amp;gt;&amp;gt; df=arcpy.mapping.ListDataFrames (mxd,"Layers")[0] &amp;gt;&amp;gt;&amp;gt; sourceLayer=arcpy.mapping.ListLayers(mxd,"orange",df)[0] &amp;gt;&amp;gt;&amp;gt; mxd2=arcpy.mapping.MapDocument(r"C:\Users\arc\Desktop\python_tutorial2.mxd") &amp;gt;&amp;gt;&amp;gt; df2=arcpy.mapping.ListDataFrames (mxd2,"Layers")[0] &amp;gt;&amp;gt;&amp;gt; updateLayer=arcpy.mapping.ListLayers(mxd2,"orange",df2)[0] Runtime error &amp;lt;type 'exceptions.IndexError'&amp;gt;: list index out of range&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What exactly does that error message mean? I wondered if it had something to do with the names in my sources ("Layers", "orange") being the same as the names in my targets, but if I change the names I get the same error. I tried running it in Catalog, and still the same error. (I tried running it in commandline and through IDLE and found I had NO idea what I was doing.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;any help would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Angela&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 20:57:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/runtime-error-amp-amp-amp-lt-type-exceptions/m-p/543533#M42385</guid>
      <dc:creator>AngelaCunningham</dc:creator>
      <dc:date>2012-08-16T20:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime error &lt;type 'exceptions.IndexError'&gt;: list index out of range</title>
      <link>https://community.esri.com/t5/python-questions/runtime-error-amp-amp-amp-lt-type-exceptions/m-p/543534#M42386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are you sure you don't want to work with your current map document?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try listing the layers to make sure you get what you expect.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;layers = arcpy.mapping.ListLayers(mxd2,"",df2) for layer in layers: &amp;nbsp;&amp;nbsp;&amp;nbsp; print layer&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 21:46:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/runtime-error-amp-amp-amp-lt-type-exceptions/m-p/543534#M42386</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-08-16T21:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime error &lt;type 'exceptions.IndexError'&gt;: list index out of range</title>
      <link>https://community.esri.com/t5/python-questions/runtime-error-amp-amp-amp-lt-type-exceptions/m-p/543535#M42387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; What exactly does that error message mean? &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would guess that the error message means the the list from which you're trying to pull the first element ([0]) is empty. I'd check the arguments to your ListLayers function to make sure they are valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The way to know for sure is to put this debug statement right before it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
layers = arcpy.mapping.ListLayers(mxd2,"orange",df2)
print len(layers), str(layers)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:32:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/runtime-error-amp-amp-amp-lt-type-exceptions/m-p/543535#M42387</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T23:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime error &lt;type 'exceptions.IndexError'&gt;: list index out of range</title>
      <link>https://community.esri.com/t5/python-questions/runtime-error-amp-amp-amp-lt-type-exceptions/m-p/543536#M42388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Matthew and Curtis,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wasn't using "CURRENT" because I wanted to use two maps at once... which I guess isn't possible if you're operating from inside Arc? I figured out how to work in IDLE and using paths instead of "CURRENT" seems to work there.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Aug 2012 15:46:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/runtime-error-amp-amp-amp-lt-type-exceptions/m-p/543536#M42388</guid>
      <dc:creator>AngelaCunningham</dc:creator>
      <dc:date>2012-08-22T15:46:57Z</dc:date>
    </item>
  </channel>
</rss>

