I am attempting to create a tool for the first time from script for ArcMap but keep getting an error message when I run the script here is my code:
import arcpy
arcpy.env.overwriteOutput = True
In_Buff_Feature = arcpy.GetParameterAsText(0)
Out_Buff = arcpy.GetParameterAsText(1)
Buffer_Dist = arcpy.GetParameter(2)
arcpy.buffer_analysis(In_Buff_Feature, Out_Buff, Buffer_Dist,)
The error I receive is:
Traceback (most recent call last):
File "C:\Users\Michaelf\Desktop\GEOG M173\Week_3_Lab.py", line 31, in <module>
arcpy.buffer_analysis(In_Buff_Feature, Out_Buff, Buffer_Dist,)
AttributeError: 'module' object has no attribute 'buffer_analysis'
Any feedback would be much appreciated!! Thank You
The arcpy.GetParameterAsText(0)
function will read an input parameter from an ArcGIS tool.
During scripting and debugging, it is simplest to hard-code the function's input variables to verify that the function is working. Once the tool is (essentially) the way you want it, create the toolbox and script tool within ArcMap.
To accept input parameters from the tool execution dialog, you'll need to specify them when creating the script tool (and change the code to accept GetParameterAsText
inputs). The best walkthrough for this is really the ArcGIS resource center.
On a secondary note: The ArcPy functions are case-sensitive, so always check that you're spelling them correctly.
arcpy.buffer_analysis(In_Buff_Feature, Out_Buff, Buffer_Dist,) # wrong
arcpy.Buffer_analysis(In_Buff_Feature, Out_Buff, Buffer_Dist) # right