Original User: SStrandThere is probably something else in your code you haven't posted that is the problem.
What exactly is the issue you were getting when it ran with no errors? Is it just you have to turn the labels on manually or something else?
Well the labels are supposed to turn on automatically as part of the larger code which takes a basic map template, geocodes an input address, buffers it, brings in wells within the buffer, labels the wells, and then exports the PDF of the map. There is more to the code and what happens but completely unrelated to anything arcpy.mapping related.I know the code isn't perfect, as it has some spots in it where things repeat themselves and could be cleaned up, but as far as I can tell, there is nothing going on which would result with the labels working in 10 but not 10.1.Here is the start to the point of labeling:# Import the arcpy and os modules.
import arcpy
import os
from arcpy import env
from subprocess import Popen, PIPE
#declare variables and set current environments
env.workspace = "I:\InfoRequest\InfoRequest.gdb"
welltypes = arcpy.GetParameterAsText(0)
inAddress = arcpy.GetParameterAsText(1)
inCity = arcpy.GetParameterAsText(2)
inState = arcpy.GetParameterAsText(3)
BufferDist = arcpy.GetParameterAsText(4)
InfoRequestNum = arcpy.GetParameterAsText(5)
ClientNam = arcpy.GetParameterAsText(6)
Purpose = arcpy.GetParameterAsText(7)
SiteNam = arcpy.GetParameterAsText(8)
includedwells = arcpy.GetParameterAsText(9)
addresstable = "AddressTable"
addresslocator = "OCAddresses_CreateAddressLoc"
geocoderesult = "AddressLocation"
TableWells = "selectedWells"
wellcasingids = "wellcasingids"
wellstyle = arcpy.mapping.Layer(r"K:\\SDE_System\\layers\\AGS10_Layers\\Wells -- All with Detailed WRMS Attributes.lyr")
Bufferresult = ("BufferRequest" + "_" + InfoRequestNum)
wellresult = ("SelectedWells" + "_" + InfoRequestNum)
export_table = ("I:\InfoRequest\InfoRequestTables\InfoRequest_" + InfoRequestNum + "_SelectedRecords.txt")
PDFPathName = ("I:\InfoRequest\InfoRequestPDF\InfoRequest_" + InfoRequestNum + ".pdf")
mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd,"Layers") [0]
#Change from layout view to data view if it's not already in data view
arcpy.mapping.MapDocument("current").activeView = "Layers"
#Workspace clean up - if the featurclasses exist, delete them.
if arcpy.Exists(geocoderesult):
arcpy.Delete_management(geocoderesult)
if arcpy.Exists(Bufferresult):
arcpy.Delete_management(Bufferresult)
if arcpy.Exists(TableWells):
arcpy.Delete_management(TableWells)
if arcpy.Exists(geocoderesult):
arcpy.Delete_management(geocoderesult)
if arcpy.Exists(Bufferresult):
arcpy.Delete_management(Bufferresult)
if arcpy.Exists(export_table):
arcpy.Delete_management(export_table)
if arcpy.Exists(wellresult):
arcpy.Delete_management(wellresult)
arcpy.AddMessage("Workspace Cleanup Complete")
#calculate table fields for geocoding from user input
cursor = arcpy.UpdateCursor(addresstable)
for row in cursor:
row.Address = inAddress
cursor.updateRow(row)
del cursor
cursor = arcpy.UpdateCursor(addresstable)
for row in cursor:
row.CITY = inCity
cursor.updateRow(row)
del cursor
cursor = arcpy.UpdateCursor(addresstable)
for row in cursor:
row.STATE = inState
cursor.updateRow(row)
del cursor
#geocode address
arcpy.GeocodeAddresses_geocoding(addresstable, addresslocator, "Address Address VISIBLE NONE; CITY CITY VISIBLE NONE; STATE STATE VISIBLE NONE ", geocoderesult)
arcpy.AddMessage("Address Located")
#buffer address
arcpy.Buffer_analysis(geocoderesult, Bufferresult, BufferDist)
arcpy.AddMessage("Buffer Complete")
#Add Address Point to the map
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
layer = arcpy.mapping.Layer(geocoderesult)
arcpy.mapping.AddLayer(df, layer)
updateLayer = arcpy.mapping.ListLayers(mxd, "AddressLocation", df)[0]
sourceLayer = arcpy.mapping.Layer(r"I:\InfoRequest\AddressLocation.lyr")
arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, False)
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
arcpy.AddMessage("Added Address Location to Map")
#Add Buffer Polygon to the map
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
layer = arcpy.mapping.Layer(Bufferresult)
arcpy.mapping.AddLayer(df, layer)
updateLayer = arcpy.mapping.ListLayers(mxd, Bufferresult, df)[0]
sourceLayer = arcpy.mapping.Layer(r"I:\InfoRequest\Buffer.lyr")
arcpy.ApplySymbologyFromLayer_management(updateLayer, sourceLayer)
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
arcpy.AddMessage("Added Buffer Polygon to Map")
#select wells by buffer and create selection layer
arcpy.SelectLayerByLocation_management(welltypes, "HAVE_THEIR_CENTER_IN", Bufferresult)
arcpy.AddMessage("Selected Wells within Buffer Area")
arcpy.CopyFeatures_management(welltypes, wellresult)
layer2 = arcpy.mapping.Layer(wellresult)
arcpy.mapping.AddLayer(df, layer2)
updateLayer2 = arcpy.mapping.ListLayers(mxd, wellresult, df)[0]
arcpy.ApplySymbologyFromLayer_management(updateLayer2, wellstyle)
if layer2.supports("LABELCLASSES"):
for lblclass in updatelayer2.labelClasses:
lblclass.showClassLabels = True
lblclass.expression = '"%s" + [WELLNM] + "%s"' % ("<CLR red='36' green='93' blue='206'>", "</CLR>")
layer2.showLabels = True
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
arcpy.AddMessage("Added Selected Wells to Map")