I'm trying complete a script that will automatically create an annotation layer from a feature layer in ArcGIS Pro but am hitting a wall with the "Annotate Selected Features" code block (all information is on the ESRI site here).

Here's my code:

import arcpy 
import os 
import os.path 
import sys 
import datetime 

arcpy.env.workspace = r"C:\Users\myname\Desktop\USACE\Working_Map\Working_map.gdb"  
aprx = arcpy.mp.ArcGISProject(r"C:\Users\myname\Desktop\USACE\Working_Map\Working_Map.aprx")  
m = aprx.listMaps("Map")[0]  
lyr = m.listLayers("WGRES_Layer")[0]  

arcpy.AnnotateSelectedFeatures_cartography(m, 'WGRES_Layer', "WGRES_LayerAnno 'Class 1'", 'GENERATE_UNPLACED')

Now the weirdest thing is the error message I get when I try to run this block; I get the message:

Traceback (most recent call last):
   File "<string>", line 15, in <module> 
AttributeError: module 'arcpy' has no attribute 'AnnotateSelectedFeatures_cartography'

Does anyone have any idea what's going on?

I get the same thing if I tried to run the tool as "AnnotateSelectedFeatures" instead (i.e. remove "_cartography" from the end).


The Annotate Selected Features tool was only added to ArcGIS Pro at 2.2. To use this tool you'll need to update from 2.1.2 to 2.2 or newer.

Reference: http://pro.arcgis.com/en/pro-app/tool-reference/cartography/cartography-toolbox-history-pro.htm

  • Thanks for the help, I got our license administrator to allow us to install the update and it's working now. Thanks! – user128533 Sep 24 '18 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.