AnsweredAssumed Answered

ArcPy delete terrain: cannot be deleted

Question asked by menno.nijhuis on Aug 29, 2014

I can't get my ArcPy script to delete a terrain. If it exists, it should be deleted. However it throws an ERROR 000317: {path} cannot be deleted

My script is a lot longer than this, but this is what it boils down to. fds is a feature dataset in a file geodatabase. The feature dataset contains a terrain with 2 associated feature classes:

- a points feature class used as masspoints
- a polygon feature class used as boundary/softclip


import os
import arcpy

fds = r'D:\Dumfries & Borders.gdb\DEM'

arcpy.env.workspace = fds
l = arcpy.ListDatasets()
for d in l:
    if arcpy.Exists(os.path.join(fds, d)):
        arcpy.Delete_management(os.path.join(fds, d))

Earlier on I tried to have the script delete the whole feature dataset at once. Didn't work either. I then decided to delete the dadasets in it one by one. The ListDatasets() lists only one: the terrain, which sparks the error mentioned above.

It is possible to delete the terrain or the feature dataset by hand in ArcCatalog, or using the Python window in ArcCatalog. However, even after closing all other programs (to preclude any locks from obstructing) except my Python interpreter (PyCharm) it still doesn't work.

So, any ideas?


edit follow-up:

removing the spaces and & from the gdb's name does not help, as ListDatasets() won't list anything now anymore. Also scriptwise trying to delete the feature dataset now throws an ERROR 000732: Input Data Element: Dataset {path} does not exist or is not supported.


(sorry no idea if this is the right place to post, couldn't find any esri/arcgis forum at all for half an hour)