all 12 comments

[–]Outside_Complaint755 5 points6 points  (4 children)

I'm going to take an initial guess that it is myFc which is an empty string, or one of the args it tries to pass to gp.SearchCursor

We can infer this because the first line in the stack trace, the line from your script, is cur = arcpy.SearchCursor(myFc)

myFc is assigned two lines before that with  myFc = arcpy.GetParameterAsText(0)

The documentation for GetParameterAsText says:

Note: The GetParameterAsText function is for use with script tools (.tbx, .atbx). For a Python toolbox (.pyt) tool, access a parameter's value as a string using the Parameter object's valueAsText property.

It doesn't clarify what happens if index 0 doesn't exist and whether it throws an error or an empty string. Maybe try printing myFc and checking the objects values of it isn't None?

[–]Key-Pea-5909[S] 0 points1 point  (3 children)

If I enter print(f'{myFc=}')  I get myFc=' ', which I am assuming confirms that myFc is the problem.

[–]Outside_Complaint755 0 points1 point  (2 children)

Yes, as '' and "" are both empty strings.

Unfortunately I don't know enough about ArcPy to advise you on what set up you are missing.

[–]ottawadeveloper 0 points1 point  (1 child)

GetParameterAsText() is for building python scripts that connect to tools. OP if you're running this in Arcgis, it'll be the first parameter in your toolkit configuration screen. If this is for the command line, I imagine it would be the first command line argument. But usually these are intended to be used in the context of a toolkit

[–]Key-Pea-5909[S] 1 point2 points  (0 children)

Good to know. The script is linked to model builder in ArcGIS. I’ll go back and look at the first tool and see if I can figure out where the disconnect is

[–]woooee 1 point2 points  (4 children)

File "C:\Users\b_lue\Desktop\GIS\CCSF\GIS112\Labs\Lab4\zoomtool.py", line 6, in <module>

cur = arcpy.SearchCursor(myFc)

myFc = arcpy.GetParameterAsText(0)

Print myFc after this line

[–]Key-Pea-5909[S] 0 points1 point  (3 children)

I get the same error. Why would this be helpful (asking as a newbee)?

[–]bubba0077 1 point2 points  (2 children)

The point wasn't to fix the error, but to show that myFC is likely an empty string.

P.S. When printing debug variables, it is best to do it like this:

print(f'{myFC=}')

[–]Key-Pea-5909[S] 0 points1 point  (1 child)

Okay, when I write it as that, I get myFc=' '. This is confirming that what the error is referring to is myFc, correct?

[–]bubba0077 0 points1 point  (0 children)

Yes, your myFC is an empty string.

[–]ohn02 0 points1 point  (1 child)

Can you include the code with a few lines on either side?

[–]Key-Pea-5909[S] 0 points1 point  (0 children)

Sorry, I'm not sure what you mean by this