The error is saying that you are trying to call a module (ExtractByMask) that does not exist in arcpy. That is because ExtractByMask lives in Spatial Analyst, which is arcpy.saI noticed that you have missed a step in your code, that is setting outExtractByMask to ExtractByMask(). This will cause errors too, see code below for the fix.You have two options to fix your initial problem:
- adding from arcpy.sa import * to the top of your code (just below import arcpy) - this is what ESRI does but it is generally not recommended. Then you can just use ExtractByMask(), not arcpy.ExtractByMask()
- call ExtractByMask directly by using arcpy.sa.ExtractByMask(), so your posted code would become (changes in red):
# Set local variables
in_raster = "C:/Users/D/Prog_Assign.gdb/R_Dataset"
in_mask_data = "C:/Users/D/Prog_Assign.gdb/Study_area_extent_shp"
#Extract by Mask
outExtractByMask = arcpy.sa.ExtractByMask (in_raster, in_mask_data)
# Save the output
outExtractByMask.save("C:/Users/D/Prog_Assign.gdb/T_Mask")