Select to view content in your preferred language

Why am I getting the error that "in_memory" does not exist?

689
6
02-11-2026 09:46 AM
rescobar
Regular Contributor

Hello, I'm getting the following error:

 

Start Time: Wednesday, February 11, 2026 12:39:31 PM
Traceback (most recent call last):
  File "\\", line 14, in <module>
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 2936, in FeatureClassToFeatureClass
    raise e
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 2933, in FeatureClassToFeatureClass
    retval = convertArcObjectToPythonObject(gp.FeatureClassToFeatureClass_conversion(*gp_fixargs((in_features, out_path, out_name, where_clause, field_mapping, config_keyword), True)))
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.ERROR 000732: Output Location: Dataset in_memory does not exist or is not supported
Failed to execute (FeatureClassToFeatureClass).

 I have the following code:

 

import arcpy
#get input layer and fields:
arcpy.env.workspace = "in_memory"
input_lyr = arcpy.GetParameterAsText(0)
fld_rank_1 = arcpy.GetParameterAsText(1)
fld_rank_2 = arcpy.GetParameterAsText(2)
out_loc = 
#Search for all records, looking at OBJECTID, first rank and second rank
fields = ["OBJECTID",fld_rank_1, fld_rank_2]
with arcpy.da.UpdateCursor(input_lyr, fields) as cursor:
    for row in cursor:
        if row[1] == row[2]:
            Temp_Selected = "Temp"
            arcpy.conversion.FeatureClassToFeatureClass(input_lyr, "in_memory","Temp_Selector","OBJECTID" +"=" +str(row[0]))
            Temp_Selected = arcpy.management.SelectLayerByLocation(input_lyr,"CONTAINS","Temp_Selector")
            arcpy.conversion.FeatureClassToFeatureClass(input_lyr, "in_memory",Temp_Selected)
            rank_lst = []
            with arcpy.da.UpdateCursor(Temp_Selected, fields) as cursor_1:
                for row_inner in cursor_1:
                    rank_lst.append(row_inner[1])
            if len(rank_lst) == 0:
                pass
            if len(rank_lst) > 0:
                if max(rank_lst) > row[1]:
                    cursor.deleteRow()
                if max(rank_lst) < row[1]:
                    pass
            arcpy.management.Delete(Temp_Selected)
            arcpy.management.Delete("Temp_Selector")
        if row[1] < row[2] or row[1] > row[2]:
            cursor.deleteRow()
Tags (3)
0 Kudos
6 Replies
RViruet
Occasional Contributor

Try using 'memory' workspace instead of 'in_memory' as it's a legacy component.

https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/basics/the-in-memory-workspace....

rescobar
Regular Contributor

I still get the same error using this line:

 

arcpy.conversion.FeatureClassToFeatureClass(input_lyr, "memory","Temp_Selector","OBJECTID" +"=" +str(row[0]))
0 Kudos
DanPatterson
MVP Esteemed Contributor

Try using the replacement tool

Export Features (Conversion)—ArcGIS Pro | Documentation

The 

Feature Class To Feature Class (Conversion)—ArcGIS Pro | Documentation

has been deprecated.  Perhaps there are some subtle differences between the two.  Note that output is usually written as ... r"memory\SomeName"

For limitations on "memory" workspaces, see the information in the following

Write geoprocessing output to memory—ArcGIS Pro | Documentation


... sort of retired...
AlfredBaldenweck
MVP Frequent Contributor

To piggyback on this, memory workspaces aren't available for some tools. It's possible that this was one of them

0 Kudos
DanPatterson
MVP Esteemed Contributor

Export Features works and even supports selections (see pre and post script images

export01.pngexport02.png


... sort of retired...
DavidSolari
MVP Regular Contributor

Doing heavy actions inside Update Cursors like creating a new feature class is a bit buggy from what I remember. Fortunately there's a solution: don't! The only thing you're doing with those new feature classes is capturing a single feature and then using that to location select the input data. Instead, try using Make Feature Layer to make lightweight views into your data that you can select freely, this should avoid the issue you have and speed up your script by a good deal.

0 Kudos