I'm having trouble removing a schema lock from a feature class in a file geodatabase after running arcpy.MakeFeatureLayer(). The typical arcpy.Delete(layer) isn't working.
I only experience this issue when running this with Pro's (1.4.1) version of python. It works fine with ArcGIS Desktop. Any ideas?
![Demo](https://community.esri.com/legacyfs/online/356834_screencast.gif)
Here's a script that demonstrates the issue:
import arcpy
arcpy.management.CreateFileGDB(r"C:\temp", "test.gdb", "CURRENT")
arcpy.management.CreateFeatureclass(r"C:\temp\test.gdb", "Test", "POLYGON", None, None, "ENABLED", "PROJCS['WGS_1984_Web_Mercator_Auxiliary_Sphere',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator_Auxiliary_Sphere'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],PARAMETER['Auxiliary_Sphere_Type',0.0],UNIT['Meter',1.0]];-20037700 -30241100 10000;
arcpy.env.workspace = "c:\\temp\\test.gdb"
layer = arcpy.MakeFeatureLayer_management('Test', 'NewTest')
arcpy.Delete_management('NewTest', 'Layer')
del layer
arcpy.env.workspace = ""
arcpy.Delete_management("C:\\temp\\test.gdb")
"""
This throws an exception:
arcgisscripting.ExecuteError: ERROR 000601: Cannot delete C:\Temp\test.gdb.
May be locked by another application.
"""