Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was working on a Python script to analyze the geometries of a feature class and write something out. It worked fine the first time, but gave an IOError each subsequent time. I narrowed the problem down to the following: (not my actual code, but shows the weird behavior)

arcpy.Exists("MyFeatureClass")  # returns true
arcpy.MakeFeatureLayer_management("MyFeatureClass", "MyFeatureLayer")
arcpy.Delete_management("MyFeatureLayer")  # returns true
arcpy.Exists("MyFeatureClass")  # returns FALSE

Can anyone think of why the feature class would become inaccessible after making a feature layer out of it? Something to do with locks?

share|improve this question
From the comments below, this might be a case to post your actual, relevant code (if possible) in case it's a specific error in it. Did you try the exact same thing as Blah238 tried from the command prompt? What about a brand new script? – nicksan Jul 3 '12 at 15:54
up vote 6 down vote accepted

Works fine here:

>>> fc = r"C:\GISData\atlantic_hurricanes_2000.shp"
>>> lyr = arcpy.MakeFeatureLayer_management(fc)
>>> lyr
<Result 'atlantic_hurricanes_2000_Lay'>
>>> lyr.getOutput(0)
<map layer u'atlantic_hurricanes_2000_Lay'>
>>> lyr = lyr.getOutput(0)
>>> arcpy.Exists(fc)
>>> arcpy.Exists(lyr)
>>> arcpy.Exists(
>>> arcpy.Delete_management(lyr)
<Result 'true'>
>>> arcpy.Exists(
>>> arcpy.Exists(fc)

Works fine with a point feature class in a file geodatabase as well:

>>> fc = r"C:\GISData\test.gdb\atlantic_hurricanes_2000"
>>> lyr = arcpy.MakeFeatureLayer_management(fc).getOutput(0)
>>> arcpy.Exists(fc)
>>> arcpy.Delete_management(lyr)
<Result 'true'>
>>> arcpy.Exists(fc)
share|improve this answer
Thanks blah - I tried this again on a fresh GDB and you're right, it works fine. Must be something in my original dataset. – Mapbert Jul 3 '12 at 0:48
Actually... it only seems to work with polygon feature classes. Any new point classes I make have the same problem. – Mapbert Jul 3 '12 at 0:53
Works fine on a file geodatabase point feature class for me as well. – blah238 Jul 3 '12 at 1:39
No matter how many new GDBs and MXDs I made, I could not get this work. But on another computer it was fine. Must be that copy of ArcGIS. – Mapbert Jul 7 '12 at 22:12

Your Answer


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.