I am trying to geocode using ArcPy Python script in ArcGIS Pro and I keep getting this error:
Traceback (most recent call last): File "C:\Users\Owner\Desktop\Python Scripting for ArcGIS\finalproject\finalpython\Gecoding.py", line 10, in text_symbol = arcpy.mp.TextSymbol() AttributeError: module 'arcpy.mp' has no attribute 'TextSymbol'
Here is the full script
import arcpy
arcpy.env.workspace = r"C:\Users\Owner\Desktop\Python Scripting for ArcGIS\finalproject\finalproject.gdb"
arcpy.env.overwriteOutput = True
road_dataset = r"C:\Users\Owner\Downloads\Harford_County_Maintained_Roads_-3767853144656662417.csv"
road_name_field = "MD_iMAP_Composite_Locator"
output_point_fc = r"C:\Users\Owner\Desktop\Python Scripting for ArcGIS\finalproject\finalproject.gdb\Harford_County_GeocodeAddres"
geocode_result = r"C:\Users\Owner\Desktop\Python Scripting for ArcGIS\finalproject\finalproject.gdb\Harford_County_GeocodeAddres"
arcpy.MakeFeatureLayer_management(geocode_result, "RoadNamePoints_layer")
label_expression = "[" + road_name_field + "]"
text_symbol = arcpy.mp.TextSymbol()
text_symbol.font.size = 10
text_symbol.font.family = "Arial"
label_placement = "NO_OVERLAP"
label_point_placement = "UPPER_RIGHT"
arcpy.mp.AddLayer(arcpy.mp.ListDataFrames(arcpy.mp.MapDocument("CURRENT"))[0], "RoadNamePoints_layer", "AUTO_ARRANGE")
for lyr in arcpy.mp.ListLayers(arcpy.mp.MapDocument("CURRENT")):
if lyr.name == "RoadNamePoints_layer":
lblClass = lyr.listLabelClasses()[0]
lblClass.expression = label_expression
lblClass.textSymbol = text_symbol
lblClass.placement = label_placement
lblClass.position = label_point_placement
arcpy.mp.refreshTOC()
arcpy.mp.refreshActiveView()
print("Geocoding and labeling completed.")
arcpy.mp.MapDocumentwhich doesn't exist in Pro. ArcGIS Pro arcpy is different from ArcMap. See "Migrating from arcpy.mapping to ArcGIS Pro"