Borealis
Borealis

Reputation: 8470

How to suppress a Python AttributeError?

When I run the ArcGIS Pro Add Geometry Attributes (Data Management) command:

arcpy.AddGeometryAttributes_management()

I receive the following error:

Traceback (most recent call last):

  File "<string>", line 1, in <module>

AttributeError: 'ToolValidator' object has no attribute 'isLicensed'

The tool performs what it needs to do and is working properly. However, doing a little research shows that this is a known bug and should be ignored:

Yes, given that there is no license requirement for the tool (https://pro.arcgis.com/en/pro-app/tool-reference/conversion/table-to-excel.htm#L_) just ignore and move on. I've pinged the gp team to make sure they can take a look at this recently reported issue. I apologize you're running into it, but looks like it isn't major...

Is there any way to completely suppress an AttributeError such as this so I do not see the error in my larger workflow?

Upvotes: 1

Views: 3679

Answers (1)

PacketLoss
PacketLoss

Reputation: 5746

Just run a try-except block around the line of code where the error is to be ignored.

try:
    arcpy.AddGeometryAttributes_management()
except AttributeError:
    pass

This will ignore the error and continue on.

Given it seems the error may be in the module, you could just use except: however this will ignore every error returned.

Upvotes: 2

Related Questions