laptop and a wrench

Erro

The following error message, "AttributeError: 'str' object has no attribute 'fields’", is returned when running the script tool from the Python toolbox.

ArcGIS Pro
Número de ID do Erro BUG-000164466
EnviadoJanuary 21, 2024
Última ModificaçãoMarch 19, 2025
Aplica-se àArcGIS Pro
Versão encontrada3.1.3
Sistema OperacionalWindows OS
Versão do Sistema Operacional10.0 64 Bit
StatusWill Not Be Addressed

Informações Adicionais

It is recommended to pass the name of the feature layer to the tool and set the symbology of the feature layer fetched from the map. This is more efficient than creating an output feature layer parameter to set the symbology.

Solução Provisória

Code to take an input feature layer, where p0 is the text name of the feature layer, and update the symbology from the layer as fetched from the active map.

p0 = parameters[0].valueAsText # set p0 in the pyt p0 = arcpy.GetParameterAsText(0) #set p0 in the script tool, aprx = arcpy.mp.ArcGISProject('CURRENT') lyr = aprx.activeMap.listLayers(p0)[0] symb = lyr.symbology symb.updateRenderer('UniqueValueRenderer') symb.renderer.fields = ['LABEL'] lyr.symbology = symb.

Otherwise, for a script tool, create an output feature layer parameter that is derived from the input layer. In this scenario, p0 is set to p0 = arcpy.GetParameter(0) in the main function. Then, at the end of the execution, set the output parameter: sym = p0.symbology sym.updateRenderer('UniqueValueRenderer') sym.renderer.fields = ['LABEL'] p0.symbology = sym arcpy.SetParameter(1, p0)

Etapas para Reproduzir

ID do Erro: BUG-000164466

Software:

  • ArcGIS Pro

Seja notificado quando o status de um erro mudar

Baixe o Aplicativo de Suporte da Esri

Descubra mais sobre este tema

Obtenha ajuda de especialistas do ArcGIS

Entre em contato com Suporte Técnico

Baixe o Aplicativo de Suporte da Esri

Ir para as opções de download