Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

i have a huge problem with an error . when i use getparameterastext and use it for searchcursor , i encounter to an error .for example the below code

import arcpy

featureClass = arcpy.GetParameterAsText(0)

populationField = arcpy.GetParameterAsText(1)

rows = arcpy.SearchCursor(featureClass)

the error is :

Runtime error : ERROR 999999: Error executing function.

the error is different in pythonwin . the error is :

Traceback (most recent call last): File "", line 1, in File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy__init__.py", line 804, in SearchCursor return gp.searchCursor(*args) File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing_base.py", line 357, in searchCursor self._gp.SearchCursor(*gp_fixargs(args))) RuntimeError: ERROR 999999: Error executing function.

please help me . thank you

share|improve this question
    
According to ESRI help.arcgis.com/EN/arcgisdesktop/10.0/help/index.html#//… this issue isn't resolved yet –  user May 30 '12 at 12:22
    
@user, that just means it's a generic error. Right? –  Dave Jul 9 '12 at 23:34
add comment

2 Answers 2

up vote 6 down vote accepted

I suggest checking what your value is in feature class in the output console. After getting the value type print featureclass

featureClass = arcpy.GetParameterAsText(0)
print featureClass
share|improve this answer
    
i don't have any problem with : featureClass = arcpy.GetParameterAsText(0) print featureClass –  wetland May 16 '11 at 10:12
    
What is the output from the print statement though? What string do you get in the console? –  Rob Clark May 16 '11 at 10:18
    
when i use 'print featureclass' i see nothing but when i print the featureclass word i see ' ' characters . –  wetland May 16 '11 at 10:28
1  
Sounds like the object passing in from the tool is incorrect. When you created the tool in your toolbox did you set the data type as FeatureClass in the Parameters dialog? –  Rob Clark May 16 '11 at 10:33
1  
No - when you set the data type when you add the script to the toolbox. You do this before you're able to run the tool. See this link - refer to step 3 - help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/… –  Rob Clark May 16 '11 at 11:06
show 2 more comments

When running from pythonwin, how are you passing the parameters to the script? You can set up a test script to ensure that things will work without having to reenter the parameters each time (as in the example below). GetParameterAsText and sys.argv will enable you to do the same thing. The only difference is the indexing since sys.argv[0] is the running script name.

import sys
import arcpy

try:
  featureClass = sys.argv[1]
  populationField = sys.argv[2]
except:
  featureClass = "c:/temp/x_pnts.shp"
  populationField = "FID"

rows = arcpy.SearchCursor(featureClass)
for row in rows:
  print  row.getValue(populationField)

EDIT Here is an example of how you would run a script with just command line entries such as the simplified version below:

import sys
import arcpy

featureClass = sys.argv[1]
populationField = sys.argv[2]

rows = arcpy.SearchCursor(featureClass)
for row in rows:
  print  row.getValue(populationField)

The entry on the command line needs to be a space delimited list as show in the image enter image description here

If you are getting error messages, then the file may be in error or the entries are incorrect.

share|improve this answer
    
now thisis my error : Traceback (most recent call last): File "<interactive input>", line 1, in <module> NameError: name 'featureClass' is not defined –  wetland May 16 '11 at 12:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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