ArcGIS 10.3.x Python 3.4 cannot delete layer

Discussion created by filipkral on Nov 13, 2015
Latest reply on Aug 5, 2016 by filipkral


I need to create a layer, then delete it and then create a layer of the same name again. The script below works as expected in Python 2.7 32 bit, but fails in Python 3.4 64 bit in ArcGIS 10.3.1.

Can anyone explain why?


import arcpy

w = "STATION=3001"
lrname = 'lr1'

# create a layer
lr =, lrname, w).getOutput(0)
print(arcpy.Exists(lrname)) # True

# delete the layer
del lr
print(arcpy.Exists(lrname)) # should be False but returns True in Python 3.4!

# create the layer again fails in Python 3.4
lr =, lrname, w).getOutput(0)
# ERROR 000725: Output Layer: Dataset lr1 already exists.

# and indeed the layer still exists after the error
print(arcpy.Exists(lrname)) # True # 1