I'm trying to use this "Select" script from http://pro.arcgis.com/en/pro-app/tool-reference/analysis/select.htm#C_GUID-81DADC1A-506C-4C5F-B9F8-945132BB8DC0

But it keeps giving me the following error:

Traceback (most recent call last):
  File "<string>", line 10, in <module>
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\analysis.py", line 91, in Select
    raise e
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\analysis.py", line 88, in Select
    retval = convertArcObjectToPythonObject(gp.Select_analysis(*gp_fixargs((in_features, out_feature_class, where_clause), True)))
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.ERROR 000732: Input Features: Dataset C:\arcGIS_Shared\Python\PythonTestScript.gdb\CAPatients does not exist or is not supportedFailed to execute (Select).

And here is my script:

# Import system modules
import arcpy
# Set local variables
in_features = r"C:\arcGIS_Shared\Python\PythonTestScript.gdb\CAPatients"
out_feature_class = r"C:\arcGIS_Shared\Python\PythonTestScript.gdb\Geocoded2"
where_clause = '"Age" = \'62\''
# Execute Select
arcpy.Select_analysis(in_features, out_feature_class, where_clause)

In the script above, the datatype for "Age" is "long"; but I have also tried replacing "Age" with "Zip_Code", which is "text".

Anyone have any ideas what I'm doing wrong or missing?

  • 1
    If it's long your query should be 'Age = 62', no quotes. It's telling you there's something it doesn't like about your in features, can you confirm the path is valid by going there in ArcCatalog (copy the path and paste into ArcCatalog folder path) and previewing the rows to ensure the data exists and isn't corrupt. Have you got C: as a "folder connection" in catalog? – Michael Stimson Dec 4 '17 at 20:45

If Age is an integer (long or short) field then instead of:

where_clause = '"Age" = \'62\''


where_clause = "Age = 62"
  • Single quotes are only needed around 62 if that value is being stored in a text field.
  • Delimiters no longer seem to be needed around field names
  • I use double quotes around where_clause strings because that makes it easy to slip in single quotes when they are needed for text fields e.g.

    where_clause = "Type = 'X'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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