<?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: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378364#M29856</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sure, and I was stumbling around a bit there too, so glad to contribute and learn something at the same time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Short answer to your question, I believe you'd use the replaceDataSource method.&amp;nbsp; The schema would need to be the same for labeling, etc., to work without further manipulation - and I think that's what you mean by using the layer file as a template, so yes that should work (I haven't tested this yet with 10.2).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A sort of one-stop page of info in the webhelp on arcpy properties/methods concerning data sources and such is here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Updating and fixing data sources with arcpy.mapping (arcpy.mapping)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Desktop » Geoprocessing » ArcPy&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000004p000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000004p000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At the bottom of that page at the link above is a good very short sample I'll copy below which fits what it sounds like you're doing - with a minor exception I'll note further below--&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
for lyr in arcpy.mapping.ListBrokenDataSources(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.supports("DATASOURCE"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.dataSource == r"C:\Project\Data\Transportation.gdb\MajorRoads":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.replaceDataSource(r"C:\Project\Data\Transportation.gdb", "FILEGDB_WORKSPACE", "Highways")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.name = "Highways"
mxd.saveACopy(r"C:\Project\Project2.mxd")
del mxd
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead of using ListBrokenDataSources above, you'd more likely need to use ListLayers (probably with a wildcard) in order to get a 'handle' on the layer in the map.&amp;nbsp; (Or, if the layer is not already in the map, use the Layer command on a lyr file as you have done previously to make a layer obj and change its source before adding to the map.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If any of that doesn't make sense, just let me know....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I didn't test this, but the code could be as simple as this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# fetches the layer from the map called WellPts from your defined mxd and df
Wells_lyr = arcpy.mapping.ListLayers(mxd, "WellPts", df)[0]

if Wells_lyr.supports("DATASOURCE"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; # replaces WellPts source with the fc, NewWellPts, in YourFileGeodatabase.gdb
&amp;nbsp;&amp;nbsp;&amp;nbsp; Wells_lyr.replaceDataSource(r"C:\YourFileGeodatabase.gdb", "FILEGDB_WORKSPACE", "NewWellPts")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:29:04 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2021-12-11T17:29:04Z</dc:date>
    <item>
      <title>Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378345#M29837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks to an earlier reply today, I'm moving along on my script but have encountered another hiccup.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've set "lyr.showLabels = True".&amp;nbsp; After looking through some other threads, it looks like I also need to set labelClasses to "showLabels = True".&amp;nbsp; The script runs with no errors but does not show the labels.&amp;nbsp; When clicking on layer properties|Labels, it shows that the labelClasses[0].expression DID accept the StateWellNumber field.&amp;nbsp; But the checkbox for showing labels is not checked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this "par for the course"?&amp;nbsp; Not a big deal (I can just go in and fill the checkbox), but it would be nice to see the labels come in as the script runs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon Mulder&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;LayerFileLocation = "H:\Documents\GIS\HydstraData" LayerName = "WellPoints.lyr" ##Define layer: lyr = arcpy.mapping.Layer(os.path.join(LayerFileLocation,LayerName)) arcpy.AddMessage(lyr) ##Show labels for WellPoints. lyr.supports("LABELCLASSES") lyr.showLabels = True lyr.labelClasses[0].expression =&amp;nbsp; "StateWellNumber" lyr.labelClasses[0].showLabels = True arcpy.RefreshActiveView()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 18:05:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378345#M29837</guid>
      <dc:creator>JonathanMulder</dc:creator>
      <dc:date>2013-12-24T18:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378346#M29838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The layer hasn't been added to the map...you can use the addLayer function or the updateLayer function in conjunction with ListLayers to get a reference to a layer already in the map.&amp;nbsp; Or to update the layer file, save or otherwise overwrite the file on disk.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 21:03:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378346#M29838</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-12-24T21:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378347#M29839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah!&amp;nbsp; Thanks for the tip!&amp;nbsp; I'll check it out soon, but right now, it's eggnog time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Happy Holidays!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon Mulder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Durham, California&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 21:31:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378347#M29839</guid>
      <dc:creator>JonathanMulder</dc:creator>
      <dc:date>2013-12-24T21:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378348#M29840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Actually, I HAVE added layers, I think.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My workflow is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Add layer (Actually a Feature class in a Geodatabase)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Symbolize Featureclass based on .lyr file previously saved.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Show labels for my WellPoint Featureclass.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could it be that my "wells_lyr" variable near the bottom of my code does not actually refer to the "AllPoints" layer (i.e. Featureclass) in the map?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon Mulder&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import arcpy.mapping
import os
OutFolderPath = "H:\Documents\GIS\HydstraData\HydstraMeasurementsDeep"
GeoDatabaseName = "HydstraMeasurementsDeep_GroundwaterElevation_Daily_Contours_20130625_20131015.gdb"
LayerFileLocation = "H:\Documents\GIS\HydstraData"

##Reference the Current map document.
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]

##arcpy.env.workspace = GeoDatabaseName
arcpy.env.workspace = "H:\Documents\GIS\HydstraData"

##Add AllPoints Featureclass to map.
Wells_lyr = os.path.join(OutFolderPath,GeoDatabaseName,"AllPoints")
##print Wells_lyr
arcpy.AddMessage(Wells_lyr)
Wells_lyr = arcpy.mapping.Layer(Wells_lyr)
arcpy.mapping.AddLayer(df, Wells_lyr, "AUTO_ARRANGE")

##Add AllContours3D Featureclass to map.
Contours_lyr = os.path.join(OutFolderPath,GeoDatabaseName,"AllContours3D")
##print Contours_lyr
arcpy.AddMessage(Contours_lyr)
Contours_lyr = arcpy.mapping.Layer(Contours_lyr)
arcpy.mapping.AddLayer(df, Contours_lyr, "AUTO_ARRANGE")

##Apply symbology from layer files.
LayerName = os.path.join(LayerFileLocation,"CasedContours.lyr")
arcpy.AddMessage(LayerName)
arcpy.ApplySymbologyFromLayer_management("AllContours3D",LayerName)
LayerName = os.path.join(LayerFileLocation,"WellPoints.lyr")
arcpy.ApplySymbologyFromLayer_management("AllPoints",LayerName)
arcpy.RefreshTOC()
arcpy.RefreshActiveView()

##Show labels for WellPoints.
Wells_lyr.supports("LABELCLASSES")
Wells_lyr.showLabels = True
Wells_lyr.labelClasses[0].expression =&amp;nbsp; "StateWellNumber"
Wells_lyr.labelClasses[0].showLabels = True
arcpy.RefreshTOC()
arcpy.RefreshActiveView()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:28:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378348#M29840</guid>
      <dc:creator>JonathanMulder</dc:creator>
      <dc:date>2021-12-11T17:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378349#M29841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try changing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;Wells_lyr.labelClasses[0].showLabels = True&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;to&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;Wells_lyr.labelClasses[0].showClassLabels = True&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Layer object has the property showLabels&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The LabelClass object has the showClassLabels property.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Dec 2013 14:19:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378349#M29841</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2013-12-26T14:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378350#M29842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, Jeff.&amp;nbsp; I gave that a try.&amp;nbsp; Everything runs (no errors), but labels still do not appear...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;They DO appear if I go into TOC, right-click on layer and enable checkbox for Show Labels.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Dec 2013 15:16:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378350#M29842</guid>
      <dc:creator>JonathanMulder</dc:creator>
      <dc:date>2013-12-26T15:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378351#M29843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Simple error I believe with the label expression - the label engine needs the brackets:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Wells_lyr.labelClasses[0].expression =&amp;nbsp; "[StateWellNumber]"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...and if you only have the 1 label class, i.e. the default, you can simply toggle the 'label features' from the layer level, as in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Wells_lyr.showLabels = True
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You already have that in the code, correctly followed by RefreshActiveView.&amp;nbsp; If you have multiple class labels, then as Jeff was saying you can selectively toggle those individual classes on/off -- but you still have the need the lyr.showLabels to 'globally' turn on/off the labeling engine for the layer - in other words, enable the labeling for those classes you've allowed it for [at the labelClasses level].&amp;nbsp; Note that you can have labelClasses showClassLabels set to True and still choose to show no labels at all via your Wells_lyr.showLabels = False&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;oops, in my test I wasn't sourced to a file gdb fc, so if you are pointed to a file gdb source, then the webhelp suggests you need double-quotes on the expression -- so try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Wells_lyr.labelClasses[0].expression =&amp;nbsp; "\"StateWellNumber\""
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...see this (LabelClass example 2, at the bottom of the page):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;LabelClass (arcpy.mapping)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Desktop » Geoprocessing » ArcPy » Mapping module&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000002t000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000002t000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:28:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378351#M29843</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T17:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378352#M29844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wayne,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your response.&amp;nbsp; I didn't realize about that convoluted syntax for accessing a field name in a geodatabase.&amp;nbsp; My code runs with no errors but labels still do not appear.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I added a snippet of code toward the bottom to print out some layer properties.&amp;nbsp; Based on my results, it still evaluates "lyr.supports("LABELCLASSES")" as False, because it doesn't proceed into the if statement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon Mulder &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: UpdateMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Fri Dec 27 07:21:29 2013&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Running script UpdateMap...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;H:\Documents\GIS\HydstraData\HydstraMeasurementsDeep\GSE_Daily_Contours_20130625_20131015.gdb\WellPoints&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;H:\Documents\GIS\HydstraData\HydstraMeasurementsDeep\GSE_Daily_Contours_20130625_20131015.gdb\AllContours3D&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;H:\Documents\GIS\HydstraData\CasedContours.lyr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer name: WellPoints&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer name: AllContours3D&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Completed script UpdateMap...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Succeeded at Fri Dec 27 07:21:34 2013 (Elapsed Time: 4.77 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import arcpy.mapping
import os
OutFolderPath = "H:\Documents\GIS\HydstraData\HydstraMeasurementsDeep"
GeoDatabaseName = "GSE_Daily_Contours_20130625_20131015.gdb"
LayerFileLocation = "H:\Documents\GIS\HydstraData"

##Reference the Current map document.
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]

ws = os.path.join(OutFolderPath,GeoDatabaseName)
arcpy.env.workspace = ws
arcpy.AddMessage(ws)
##arcpy.env.workspace = "H:\Documents\GIS\HydstraData"

##Add AllPoints Featureclass to map.
Wells_lyr = os.path.join(OutFolderPath,GeoDatabaseName,"WellPoints")
##print Wells_lyr
arcpy.AddMessage(Wells_lyr)
Wells_lyr = arcpy.mapping.Layer(Wells_lyr)
arcpy.mapping.AddLayer(df, Wells_lyr, "AUTO_ARRANGE")

##Add AllContours3D Featureclass to map.
Contours_lyr = os.path.join(OutFolderPath,GeoDatabaseName,"AllContours3D")
##print Contours_lyr
arcpy.AddMessage(Contours_lyr)
Contours_lyr = arcpy.mapping.Layer(Contours_lyr)
arcpy.mapping.AddLayer(df, Contours_lyr, "AUTO_ARRANGE")

##Apply symbology from layer files.
LayerName = os.path.join(LayerFileLocation,"CasedContours.lyr")
arcpy.AddMessage(LayerName)
arcpy.ApplySymbologyFromLayer_management("AllContours3D",LayerName)
LayerName = os.path.join(LayerFileLocation,"WellPoints.lyr")
arcpy.ApplySymbologyFromLayer_management("WellPoints",LayerName)
arcpy.RefreshTOC()
arcpy.RefreshActiveView()

##Show labels for WellPoints.
arcpy.AddMessage(Wells_lyr)
Wells_lyr.supports("LABELCLASSES")
Wells_lyr.showLabels = True
Wells_lyr.labelClasses[0].expression =&amp;nbsp; "\"StateWellNumber\""
Wells_lyr.labelClasses[0].showClassLabels = True

arcpy.RefreshActiveView()
for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage( "Layer name: " + lyr.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.supports("LABELCLASSES"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.showLabels:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage( "Layer name: " + lyr.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for lblClass in lyr.labelClasses:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lblClass.showClassLabels:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage( "&amp;nbsp;&amp;nbsp; Class Name:&amp;nbsp; " + lblClass.className)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("&amp;nbsp;&amp;nbsp;&amp;nbsp; Expression:&amp;nbsp; " + lblClass.expression)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL Query:&amp;nbsp;&amp;nbsp; " + lblClass.SQLQuery)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:28:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378352#M29844</guid>
      <dc:creator>JonathanMulder</dc:creator>
      <dc:date>2021-12-11T17:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378353#M29845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Interesting - probably better to troubleshoot within ArcMap's Python window so that you'd get more informative messages back, but since you've already made this a script tool, try replacing your ListLayers section of code with the snippet below and see what messages you get back.&amp;nbsp; A confusing little thing you coded that is making this a little trickier is you have 2 identical messages printing; the 2nd one isn't printing obviously but you have 2 'if' statements to eval to true in order for the 2nd one to print --- so you still don't really know what's up....need more feedback - if the below doesn't work to at least give you a better lead (this is not a solution, just an attempt to get back more of a clue), try attaching a gdb sample of your layers if you can for someone to work with.&amp;nbsp; You are working with 10.2?&amp;nbsp; I realize you are new to this; someone can write shorter more concise code for you to study/test/etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage( "Layer name: " + lyr.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.supports("SHOWLABELS"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(lyr.name + " supports labeling.")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Layer labeling is on?:&amp;nbsp; " + str(lyr.showLabels))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for lblClass in lyr.labelClasses:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage( "&amp;nbsp;&amp;nbsp; Class Name:&amp;nbsp; " + lblClass.className)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("&amp;nbsp;&amp;nbsp;&amp;nbsp; Expression:&amp;nbsp; " + lblClass.expression)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL Query:&amp;nbsp;&amp;nbsp; " + lblClass.SQLQuery)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Label class is on?:&amp;nbsp;&amp;nbsp; " + str(lblClass.showClassLabels))
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:29:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378353#M29845</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T17:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378354#M29846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Wayne,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll give it a try in a little bit.&amp;nbsp; Currently, I have two other ArcMap sessions running on imagery processing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, I'm using 10.2 version (Home Use license from about 45 days ago.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Question -- Why is the fourth line indented an additional 8 spaces and not 4?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I took the 3-day scripting course about 2 months ago in Sacramento (Jeff Bilos(?)).&amp;nbsp; I didn't learn much about the Python window.&amp;nbsp; How could I query in the window if the "lyr.supports("SHOWLABELS")"?&amp;nbsp; I assume that's what you alluding to...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon Mulder&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 14:59:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378354#M29846</guid>
      <dc:creator>JonathanMulder</dc:creator>
      <dc:date>2013-12-27T14:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378355#M29847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;oh, probably where I took out your other 'if' statement...it'll probably still run with that indention, but if not you can 'unindent' the entire region.&amp;nbsp; If you don't already know how, if you open the script to edit in IDLE, you can select the line and of course the following lines, then go to the Format menu (I think it is, but you may have to look around...), and I think the item you need is 'Dedent'.&amp;nbsp; Anyway, try that- it's quick and easy and less error-prone than all the backspacing...good luck.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...and about your last question, making print statements in the Python window of ArcMap - once you've defined your variables (mxd, lyr, etc.), you could simply use print:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print str(lyr.supports("SHOWLABELS"))&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 15:08:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378355#M29847</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-12-27T15:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378356#M29848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is the result of the script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;=================================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: UpdateMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Fri Dec 27 09:07:02 2013&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Running script UpdateMap...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;H:\Documents\GIS\HydstraData\HydstraMeasurementsDeep\GSE_Daily_Contours_20130625_20131015.gdb\WellPoints&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;H:\Documents\GIS\HydstraData\HydstraMeasurementsDeep\GSE_Daily_Contours_20130625_20131015.gdb\AllContours3D&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;H:\Documents\GIS\HydstraData\CasedContours.lyr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer name: WellPoints&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WellPoints supports labeling.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer labeling is on?:&amp;nbsp; False&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Class Name:&amp;nbsp; Default&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Expression:&amp;nbsp; [StateWellNumber]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL Query:&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Label class is on?:&amp;nbsp;&amp;nbsp; True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer name: AllContours3D&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AllContours3D supports labeling.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer labeling is on?:&amp;nbsp; False&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Class Name:&amp;nbsp; Default&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Expression:&amp;nbsp; [ContourDate]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL Query:&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Label class is on?:&amp;nbsp;&amp;nbsp; True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Completed script UpdateMap...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Succeeded at Fri Dec 27 09:07:04 2013 (Elapsed Time: 1.39 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;===================================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, it's saying that the WellPoints layer DOES support labeling, but that the Layer labeling is False.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I kind of thought that the "Wells_lyr.showLabels = True" would make Layer labeling True.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon Mulder&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 15:14:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378356#M29848</guid>
      <dc:creator>JonathanMulder</dc:creator>
      <dc:date>2013-12-27T15:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378357#M29849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hmmm, now we're getting somewhere.&amp;nbsp; I don't have ArcMap open at the moment, but can you try reordering the following statements, so that the showLabels statement is after defining the class labeling - not that it should make a difference, but let's see (and you don't need the 'supports' statement for LABELCLASSES):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;##Show labels for WellPoints.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage(Wells_lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wells_lyr.labelClasses[0].expression =&amp;nbsp; "\"StateWellNumber\""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wells_lyr.labelClasses[0].showClassLabels = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wells_lyr.showLabels = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I question the expression feedback you got:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: [StateWellNumber]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 15:22:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378357#M29849</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-12-27T15:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378358#M29850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think I'm getting hung up on the line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wells_lyr.labelClasses[0].expression =&amp;nbsp; "\""StateWellNumber"\""&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the site you referred me to, &lt;/SPAN&gt;&lt;STRONG&gt;[&lt;/STRONG&gt;&lt;SPAN&gt; should be replaced with &lt;/SPAN&gt;&lt;STRONG&gt;"\""&lt;/STRONG&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;STRONG&gt;]&lt;/STRONG&gt;&lt;SPAN&gt; should be replaced with &lt;/SPAN&gt;&lt;STRONG&gt;"\""&lt;/STRONG&gt;&lt;SPAN&gt;.&amp;nbsp; But when I do that it errors out saying:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;==========================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: UpdateMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Fri Dec 27 09:41:01 2013&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Running script UpdateMap...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SyntaxError: invalid syntax (UpdateMxd20131225.py, line 48)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (UpdateMap).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Fri Dec 27 09:41:01 2013 (Elapsed Time: 0.01 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;==========================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But, when I use &lt;/SPAN&gt;&lt;STRONG&gt;"\"StateWellNumber\""&lt;/STRONG&gt;&lt;SPAN&gt; it does not error out.&amp;nbsp; Am I missing something here?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon Mulder&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 15:49:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378358#M29850</guid>
      <dc:creator>JonathanMulder</dc:creator>
      <dc:date>2013-12-27T15:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378359#M29851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have too many quotes - the \ character tells Python to interpret the following character as part of the string to pass (and not signify the end of the string), understand?&amp;nbsp; So when you enter the expression, "\""StateWellNumber"\"", Python is really trying to interpret 3 things (", StateWellNumber, ") that don't make sense (and it's expecting a single string).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, as a single string (that you said it did not error on, a good thing) it should have been:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; "\"StateWellNumber"\"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which in turn is interpreted by Python as "StateWellNumber" (with the double-quotes).&amp;nbsp; However, ArcMap itself may not interpret this with its label engine as expected and not return errors --- so do this as a test:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Open the layer properties in ArcMap and enter the expression in the label class as StateWellNumber --- verify the expression (which produces the label?) - I think for file gdbs, either will work, with or without the double-quotes.&amp;nbsp; When you click verify, if you get an empty text box sample as a result, hello houston that is a failure to launch...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So what I'm getting at here is to use the expression that tests positive in ArcMap as you test interactively...change your code accordingly.&amp;nbsp; Realize that for multiple classes you must have the labeling 'turned on' at 2 levels -- you can 'see' this from the layer properties as well if you check directly within ArcMap.&amp;nbsp; There is a 'class level' and at a higher level, the 'layer level'....at the layer level, toggling labeling off turns all class labels off (although still checked 'on' at the class level).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know what your progress is...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 16:14:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378359#M29851</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-12-27T16:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378360#M29852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wayne,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;Everything seems to work, but still no labels visible.&amp;nbsp; I've confirmed that "StateWellNumber" is the proper field, and I'm using your syntax for double quotes (now that I understand it more).&amp;nbsp; In any case, I condensed down my dataset to just two days of contours (ultimately, this will have a time property to view contour changes over time).&amp;nbsp; Can I send you my geodatabase, layer files, and script?&amp;nbsp; I tried to attach a zip file here, but I'm not able to do that.&amp;nbsp; Possibly contact me via e-mail (&lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:mulder@water.ca.gov"&gt;mulder@water.ca.gov&lt;/A&gt;&lt;SPAN&gt;) and I can send you the zip file (which would be better than a bunch of separate files because it would retain the directory structure).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon Mulder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;California Department of Water Resources&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 17:57:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378360#M29852</guid>
      <dc:creator>JonathanMulder</dc:creator>
      <dc:date>2013-12-27T17:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378361#M29853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay, yes I am curious - all testing on my test data worked fine, so I'd like to see what's going on with yours...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If your private message feature of your forum acct is enabled, I'll send you a msg with my email addy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise if there's any convenient way for you to clip a sample of the relevant data, you should pkg that up for shipment....either way, but when I send it back likely that's what I would do.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just checking one more thing, I think you said earlier that you could 'manually' toggle on labels in ArcMap.&amp;nbsp; Is that still true?...and for successful labeling, what is the expression written to the Layer Properties, Labeling tab, class window text box?&amp;nbsp; I asked you to check that, but if you don't know what I mean or that checked out okay already, then just send the map, lyr files, gdb, just whatever is needed to make it work.&amp;nbsp; If you don't clip, then I don't think the contours layer is necessary - I imagine that one is huge and the failure was evident with the wells point layer, correct?&amp;nbsp; So that one should be sufficient.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...one more thing...I was looking at something else, so how time-sensitive is this when you need it back?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 18:17:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378361#M29853</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-12-27T18:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378362#M29854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jon, I received the data and corrected the script - only where the labeling is concerned for the well points layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First of all, the file gdb labeling does indeed use brackets...the field must be referenced - I should've known actually the text I had you insert would actually be interpreted as raw text, i.e. every label would simply be the text, StateWellNumber, lol!&amp;nbsp; That was my mistake...but not the primary problem.&amp;nbsp; Your problem was the labels wouldn't turn on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just before Jeff's post you made a statement that turns out after further testing to be essentially true:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"Could it be that my "wells_lyr" variable near the bottom of my code does not actually refer to the "AllPoints" layer (i.e. Featureclass) in the map?"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Nice catch - so the fix was to manipulate the labeling before adding the layer to the map.&amp;nbsp; I don't know if this is a design feature or a bug, but at least there's a relatively simple workaround...I sent you the script pared down to a few lines designed for you to simply load and run in ArcMap to see it in action.&amp;nbsp; The relevant lines I'll post below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;WellPtsLyrFile = os.path.join(rootPath, 'WellPoints201312271743.lyr') Wells_lyr = arcpy.mapping.Layer(WellPtsLyrFile)&amp;nbsp; ##Show labels for WellPoints. if Wells_lyr.supports("LABELCLASSES"): &amp;nbsp;&amp;nbsp;&amp;nbsp; Wells_lyr.labelClasses[0].expression =&amp;nbsp; "[StateWellNumber]"&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ## class labeling is on by default; showClassLabels is optional. &amp;nbsp;&amp;nbsp;&amp;nbsp; #Wells_lyr.labelClasses[0].showClassLabels = True &amp;nbsp;&amp;nbsp;&amp;nbsp; Wells_lyr.showLabels = True&amp;nbsp; arcpy.mapping.AddLayer(df, Wells_lyr, "AUTO_ARRANGE")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that finally clears up any lingering confusion.&amp;nbsp; Actually the showClassLabels property I can see could be pretty useful, say if you defined multiple label classes in a single layer file, then wanted to run for example multiple PDF exports showing only certain label classes...with them already defined, all you'd have to manage is switching them on/off as needed in a loop to produce your PDF pages.&amp;nbsp; (Or, say you had multiple data frames - same principle applies, using the same lyr file but managing labeling in various different ways for each data frame.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 23:03:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378362#M29854</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-12-27T23:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378363#M29855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gosh Wayne!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much!&amp;nbsp; Obviously, I was getting buried in the weeds instead of looking at the big picture.&amp;nbsp; But let me ask a (hopefully) simple question.&amp;nbsp; This script will be used for running many different groundwater level scenarios from different sets of WellPoints and Contours featureclasses.&amp;nbsp; I'm thinking that I'd have two layer files that act as templates for the featureclasses.&amp;nbsp; As I understand your script, it is loading the actual well data that is currently associated with the layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;After the WellPtsLayerFile is added to the document, is there a way to re-direct the layer reference to another featureclass?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once again, thanks very much for looking at my script.&amp;nbsp; And thanks for a quick tutorial on using the ArcMap Python window.&amp;nbsp; Obviously, the three-day course I took only whetted my appetite.&amp;nbsp; Now I need to go to a follow-up class with plenty of questions!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon Mulder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;California Department of Water Resources&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Dec 2013 16:03:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378363#M29855</guid>
      <dc:creator>JonathanMulder</dc:creator>
      <dc:date>2013-12-28T16:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True</title>
      <link>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378364#M29856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sure, and I was stumbling around a bit there too, so glad to contribute and learn something at the same time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Short answer to your question, I believe you'd use the replaceDataSource method.&amp;nbsp; The schema would need to be the same for labeling, etc., to work without further manipulation - and I think that's what you mean by using the layer file as a template, so yes that should work (I haven't tested this yet with 10.2).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A sort of one-stop page of info in the webhelp on arcpy properties/methods concerning data sources and such is here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Updating and fixing data sources with arcpy.mapping (arcpy.mapping)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Desktop » Geoprocessing » ArcPy&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000004p000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000004p000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At the bottom of that page at the link above is a good very short sample I'll copy below which fits what it sounds like you're doing - with a minor exception I'll note further below--&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
for lyr in arcpy.mapping.ListBrokenDataSources(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.supports("DATASOURCE"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.dataSource == r"C:\Project\Data\Transportation.gdb\MajorRoads":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.replaceDataSource(r"C:\Project\Data\Transportation.gdb", "FILEGDB_WORKSPACE", "Highways")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.name = "Highways"
mxd.saveACopy(r"C:\Project\Project2.mxd")
del mxd
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead of using ListBrokenDataSources above, you'd more likely need to use ListLayers (probably with a wildcard) in order to get a 'handle' on the layer in the map.&amp;nbsp; (Or, if the layer is not already in the map, use the Layer command on a lyr file as you have done previously to make a layer obj and change its source before adding to the map.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If any of that doesn't make sense, just let me know....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I didn't test this, but the code could be as simple as this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# fetches the layer from the map called WellPts from your defined mxd and df
Wells_lyr = arcpy.mapping.ListLayers(mxd, "WellPts", df)[0]

if Wells_lyr.supports("DATASOURCE"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; # replaces WellPts source with the fc, NewWellPts, in YourFileGeodatabase.gdb
&amp;nbsp;&amp;nbsp;&amp;nbsp; Wells_lyr.replaceDataSource(r"C:\YourFileGeodatabase.gdb", "FILEGDB_WORKSPACE", "NewWellPts")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:29:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labels-still-not-visible-after-setting-lyr/m-p/378364#M29856</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T17:29:04Z</dc:date>
    </item>
  </channel>
</rss>

