I am running a line of code in a Python 2.7 environment using arcpy.SelectLayerByAttribute_management
:
fl_haz_selects = arcpy.SelectLayerByAttribute_management(S_Fld_Haz_Ar, "NEW_SELECTION", "\"DFIRM_ID\" = '{}'".format(fipC))
It runs perfectly fine in Python 3.6. Now I am getting the following errors. What am I doing incorrectly here? Note: S_FLD_Haz_Ar
is a shapefile. Do I just need to make it into a layer? I am trying to avoid making a physical layer.
Traceback (most recent call last): File "", line 3, in File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py", line 7713, in SelectLayerByAttribute raise e ExecuteError: Failed to execute. Parameters are not valid. The value cannot be a feature class ERROR 000840: The value is not a Raster Layer. ERROR 000840: The value is not a Mosaic Layer. Failed to execute (SelectLayerByAttribute).
It needs to be a feature layer, but that doesn't mean you have to make a LYR file. Just use Make Feature Layer—Help | ArcGIS Desktop and look at Code Sample 2.