<?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: ListLayers error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512198#M40285</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I went back to Pyscripter and try again and change from gridlayers to imagelayer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I see that ListLayers had the errror so I am thinking that by looking at the Varibales and it is not there...&lt;/P&gt;&lt;P&gt;is that why it&amp;nbsp; could not run it ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Feb 2015 19:26:24 GMT</pubDate>
    <dc:creator>DEAF_PROBERT_68</dc:creator>
    <dc:date>2015-02-10T19:26:24Z</dc:date>
    <item>
      <title>ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512186#M40273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having an syntax error from Pyscripter here and not sure why but I have a shapefile at the top of the TOC list which is the first and should be number zero&amp;nbsp; when writing a listlayers as a zero&amp;nbsp; but I still get the error .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error is :&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\Student\python\GeoTIFF.py", line 16, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gridlayer = arcpy.mapping.ListLayers(mxd,'JERGRIDINDEX', df,)[0]&lt;/P&gt;&lt;P&gt;IndexError: list index out of range&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take a look here the sytanx:: gridlayer = arcpy.mapping.ListLayers(mxd,'JERGRIDINDEX', df,)[0]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 18:13:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512186#M40273</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-09T18:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512187#M40274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you be able to post all of your code?&amp;nbsp; This will help troubleshoot this faster.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 18:26:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512187#M40274</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2015-02-09T18:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512188#M40275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here you go:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mport arcpy.mapping, os&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument (r"E:\workspace\Test.mxd")&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = r"E:/workspace/images/"&lt;/P&gt;&lt;P&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/P&gt;&lt;P&gt;df.scale = 40000&lt;/P&gt;&lt;P&gt;gridlayer = arcpy.mapping.ListLayers(mxd,'JERGRIDINDEX', df,)[0]&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management(gridlayer, "NEW_SELECTION")&lt;/P&gt;&lt;P&gt;for row in arcpy.SearchCursor(gridlayer):&lt;/P&gt;&lt;P&gt;&amp;nbsp; df.panToExtent(row.shape.extent)&lt;/P&gt;&lt;P&gt;&amp;nbsp; arcpy.RefreshActiveView()&lt;/P&gt;&lt;P&gt;&amp;nbsp; filename = "E:/workspace/images/" + \&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; str(row.getValue("PageNumber")).zfill(4) + ".tif"&lt;/P&gt;&lt;P&gt;&amp;nbsp; arcpy.mapping.ExportToTIFF(mxd, filename, df, df_export_width= 65000, df_export_height=30000,geoTIFF_tags=True)&lt;/P&gt;&lt;P&gt;##&amp;nbsp; arcpy.mapping.ExportToTIFF(mxd, filename, df, df_export_width= 1280, \&lt;/P&gt;&lt;P&gt;##&amp;nbsp;&amp;nbsp;&amp;nbsp; df_export_height=440, geoTIFF_tags=True)&lt;/P&gt;&lt;P&gt;print arcpy.GetMessages()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 18:33:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512188#M40275</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-09T18:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512189#M40276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Everything looks correct, unless you are mis-spelling the layer name.&amp;nbsp; However, since you want the first layer, you will not have to specify a name.&amp;nbsp; Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14235073012529879" jivemacro_uid="_14235073012529879"&gt;&lt;P&gt;gridlayer = arcpy.mapping.ListLayers(mxd,'', df,)[0]&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing I did just notice is the arcpy.env.workspace.&amp;nbsp; Since you are specifying an 'r' before the path, you will want to change the forward slashes to backslashes.&amp;nbsp; Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14235074127494475 jive_text_macro" jivemacro_uid="_14235074127494475"&gt;&lt;P&gt;arcpy.env.workspace = r"E:\workspace\images"&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 18:41:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512189#M40276</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2015-02-09T18:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512190#M40277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did the same thing what you suggest. I can try and run it from Python window but Pyscripter should be able to recongize it.&amp;nbsp; Can I run this script from Pyscripter rather than in python window ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 18:56:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512190#M40277</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-09T18:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512191#M40278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you should be able to run this in Pyscripter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 19:11:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512191#M40278</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2015-02-09T19:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512192#M40279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can I sync this Pyscripter to Arcmap ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 19:18:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512192#M40279</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-09T19:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512193#M40280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not quite sure what you mean.&amp;nbsp; When the code is executed in Pyscripter, you will not see the map's extent updated.&amp;nbsp; However, you should still have the TIFF file created.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 19:24:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512193#M40280</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2015-02-09T19:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512194#M40281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am thinking maybe it is not working.How can Pyscripter communicate with ArcMap if I write these codes ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 19:37:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512194#M40281</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-09T19:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512195#M40282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My Pyscripter versions is 2.5.3.0 x86 Is that correct for ArcGIS 10.1 Python 2.7 ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 19:40:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512195#M40282</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-09T19:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512196#M40283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check out the &lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Debugging_script_tools/00150000000m000000/"&gt;Execute and debug your tool&lt;/A&gt; section for help attaching pyscripter to ArcMap for debugging.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 19:55:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512196#M40283</guid>
      <dc:creator>GusMartinka</dc:creator>
      <dc:date>2015-02-09T19:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512197#M40284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should be OK with that version of PyScripter (it hasn't been updated in years). If it was installed after ArcGIS, it will probably find the python installation that comes with ArcGIS in C:\Python27\ArcGIS10.1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can check the Python path in the Tools menu to see which paths are used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you run some simple code like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
print arcpy.ProductInfo()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It will print the license level of ArcGIS. If this works you can work with PyScripter and ArcGIS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In you code you reference the mxd document by path instead of using the keyword "CURRENT". &lt;/P&gt;&lt;P&gt;That is all it takes as &lt;A href="https://community.esri.com/migrated-users/8586" target="_blank"&gt;Jake Skinner&lt;/A&gt;‌ already explained.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running the code from as stand alone script (from output ArcMap) will open the MXD on the background and process it. There is not much more to it...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:25:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512197#M40284</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T22:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512198#M40285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I went back to Pyscripter and try again and change from gridlayers to imagelayer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I see that ListLayers had the errror so I am thinking that by looking at the Varibales and it is not there...&lt;/P&gt;&lt;P&gt;is that why it&amp;nbsp; could not run it ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 19:26:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512198#M40285</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-10T19:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: ListLayers error</title>
      <link>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512199#M40286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Never mind. I did checked and ListLayers still there and I think the main problem is I copied and paste when I first started and gave me bunch of problems so I am thinking instead of copy and past . I might have to do typing rather than copy and paste ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you say ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 20:05:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listlayers-error/m-p/512199#M40286</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-10T20:05:49Z</dc:date>
    </item>
  </channel>
</rss>

