I have a script and when I run the ZonalStatisticsAsTable I get this error:

  • File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\geoprocessing_base.py", line 510, in return lambda *args: val(gp_fixargs(args, True)) ExecuteError: Failed to execute. Parameters are not valid. ERROR 000824: The tool is not licensed. Failed to execute (ZonalStatisticsAsTable).

My code is:

flist = []
    for file in files:
        if os.path.isfile(os.path.join(root,file)) and file.endswith('.shp'):

    arcpy.env.workspace =r"Z:\EMSV-057_AOIs_Reshape\5_Process\1_TaskA\ModelBuilder\Pruebas_MV\EU_AOI\CAPAS"
    for z in flist:

       erase=arcpy.Erase_analysis(shape,"C:\\OSM_coastlines\\water_polygons.shp", "Tierra", cluster_tolerance="")

       tZONA=arcpy.gp.ZonalStatisticsAsTable_sa(erase, "FID", raster, "Tabla", "NODATA", "ALL")

1 Answer 1


It seems you either don't have a Spatial Analyst license, or you need to enable it. How to enable extensions is described in the Help page on Using Extensions in ArcGIS.

You may also have to import and checkout the extension in your code. modified example from the documentation:

import arcpy
from arcpy.sa import *

class LicenseError(Exception):

    if arcpy.CheckExtension("Spatial") == "Available":

        # raise a custom exception
        raise LicenseError

      #Your main code here using spatial analyst

except LicenseError:
    print("Spatial Analyst license is unavailable")
except arcpy.ExecuteError:
  • 1
    I have active all extensions and when I calculate the statistics in ArcGIS I get its. But I if I run my python.py file I will get the error message
    – MikV89
    Commented Sep 17, 2020 at 4:41
  • Thanks for the update - you may need to checkout the extension in your program. See my edits above. Commented Sep 17, 2020 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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