Arcpy.env.overwriteOutput = True not working for one dataset
I am doing a basic copy from sde database to file geodatabase. I have a loop going through each feature dataset in the sde database, this loop is really basic it just uses
arcpy.Copy_Managementto copy everything over. I have
arcpy.env.overwriteOutput = Trueat the beginning of the script after importing in arcpy. It does not throw me that error for any other feature dataset, even though they are also overwriting a FeatureDataset with the same name.
the error it throws is :
ERROR 000605: Output Sidewalk already exists within C:UsersstackDesktopTestingscriptsDump.gdbSidewalk. Failed to execute (Copy).
I even added
arcpy.env.overwriteOutput = Trueto the beginning to of the function. I also put a line in the exception the prints out the status of
env.overwriteOutputand it is true at that time when it breaks.
This does not make any sense to me. Has anyone else had this problem?
As discussed in the comments, this appears to be a bug of some sort. Use the workaround
if arcpy.Exists (fc): arcpy.Delete_management (fc)
I know this is very old, but I thought I'd add another solution that I figured out after coming across the same error just now, as it may help others that look here in future.
Make sure that feature class is not in use anywhere else.
In my case I had set
arcpy.env.overwriteOutput = Truebut got the error
ExecuteError: ERROR 000258: Output C:lahlahlah already existswhile that feature class was being displayed in ArcMap. I then closed ArcMap, and ran the script again (in PyScripter) and the script worked fine with no errors.
NB: ArcMap is very bad at hanging on to things it no longer needs. In some cases removing a layer in ArcMap, or even opening a new blank map may not be enough. You may have to actually close ArcMap completely.
Also, make sure the feature class is not being used by any other processes. Eg, ArcCatalog, ArcGIS Server (eg in a map service), some other Python script, etc, etc.