get tied up in a process with PyScripter
What process(es) are you performing? Could it be that you are running a cursor or something on the grid attribute tables and forgetting to delete the cursor objects (and therefore the locks are persisting)?
It would help if you posted your code.
Normally, the grids should delete just fine. I have many a script that loops, does all sorts of fancy stuff, and then cleans up the temp processing grids upon each iteration. There must be something specific you are doing (or not doing) that prevents deleteing the grids.
def delete_temps(arg1,arg2,arg3): gp.Delete_management("g1tmp.img") temps, temps2 = range(1,arg1), [rasts(y) for y in range(1,arg2)] [gp.Delete_management(DOW + "_temp" + str(y) + ".shp") for y in temps] if arg1 > 4: [gp.Delete_management(y) for y in (DOW + "_segtemp1.img", DOW + "_segtemp2.shp")] if arg3 != 0: temps3 = range(1,arg3) [gp.Delete_management(DOW + "_final" + str(y) + ".shp") for y in temps3] try: [gp.Delete_management(y) for y in temps2] except: for y in temps2: for x in glob.glob(gp.Workspace + "\\g" + str(y) + "*"): try: os.remove(x) except: shutil.rmtree(x) tables = gp.ListTables("g*","INFO") table = tables.next() while table: gp.Delete_management(table) table = tables.next()
try: gp.CheckOutExtension("Spatial") if Ecotype == "Droge Vleermuis (Gewone dwergvleermuis)" or Ecotype == "Natte Vleermuis (Watervleermuis)": reclasslist = [0, MDVcd, 1] else: reclasslist = [0, MDAcd / 2, 1] reclassifyRange = RemapRange([reclasslist]) outDispBuffBinary = Reclassify(DispBuff, "Value", reclassifyRange, "DATA") outDispBuffBinary.save(DispBuffBinary) except: print gp.GetMessages() # 6.3 Region group binary try: gp.CheckOutExtension("Spatial") outDispBuffRG = RegionGroup(DispBuffBinary, "EIGHT", "WITHIN", "NO_LINK", "") outDispBuffRG.save(DispBuffRG) except: print gp.GetMessages() # 6.4 Convert RegionGroup to shapefile try: gp.RasterToPolygon_conversion(DispBuffRG, DispBuffVector, "SIMPLIFY") except: print gp.GetMessages() # 6.5 Delete stepping stone files try: gp.Delete_management(DispBuffBinary) gp.Delete_management(DispBuffRG) except: print gp.GetMessages()
One thing I haven't tried yet is deleting feature layers... the rest of the code creates anywhere between 3-9 feature layers depending on how the output behaves. I never bothered to delete these since they are deleted automatically when the session is over (right?), but they might be causing the lock since they are used for creating some of the shapefiles and grid rasters.
# note layer and views come BEFORE the data sets in the list lyrFeat,lyrRast,tvTable,tmpFeat,tmpRast = [None] * 5 ... try: # work goes here except: ... finally: try: del Row, Rows # any cursors deleted here except: pass # the following is list copied and pasted from above for f in lyrFeat,lyrRast,tvTable,tmpFeat,tmpRast: try: if f: gp.Delete(f) except: pass