Select to view content in your preferred language

Problem Deleting scratchGDB after script runs

12067
11
02-27-2014 05:22 AM
MarcCusumano
Regular Contributor
I have a script running that does a bit of spatial analysis, creates a relationship table and exports layout images to JPEG for report.

It runs great, but I am having a problem doing proper cleanup. I go to delete the scratchGDB using arcpy.delete, and it works fine. The problem is that a leftover scratch.gdb remains in the workspace directory.

After running arcpy.delete the leftover scratch.gdb is not a true geodatabase; in ArcCatalog it appears as a folder with a plus to the left of it. Drilling down on the plus and there is nothing in there.

I also added a line to delete that file in python and I get this:

[Error 5] Access is denied: 'D:\\gis\\Data\\scratch.gdb'

Sometimes the script works fine without deleting the scratch.gdb (it simply overwrites), other times it tells me it cannot create the initial output and fails. I would appreciate any help.
Tags (2)
11 Replies
DanPatterson_Retired
MVP Emeritus

hmmmm, I suspect it will stop when you reboot... never while something that you aren't sure is going to finish

0 Kudos
PriscillaCole
Occasional Contributor

"Did you try turning it off and on again?" -IT Crowd

I was also having this problem. arcpy.Delete_management(GDB_path) would not remove my GDB, and left a weird folder behind. I attempted the while-loop approach (mentioned above), but that turned out to be an infinite loop, and I had to kill ArcMap to stop it.  When I restarted ArcMap, the GDB hadn't been deleted. For fun, I tried running the original command again: arcpy.Delete_management(GDB_path). And it worked!

Restart to the rescue again!