Hi all,
I am running into something really weird and I was wondering if anyone could tell me what's happening here.
I have a coverage that I'm trying to describe.
fdList = arcpy.ListDatasets()
# Print feature classes in Datasets
if fdList:
for fd in fdList:
print(fd)
desc= (arcpy.da.Describe(fd))
#print(desc)
print(desc['catalogPath'], desc['datasetType'])
if desc['datasetType'] == "FeatureDataset":
print("true")
''' Yields:'''
# T:\...\nhd FeatureDataset
# true
# T:\...\nhdpt FeatureDataset
# true
# T:\...\nhdduu FeatureDataset
# true
However, if I try to do anything with it, I get an error:
if fdList:
for fd in fdList:
#print(fd)
desc= (arcpy.da.Describe(fd))
#print(desc)
print(desc['catalogPath'], desc['datasetType'])
if desc['datasetType'] == "FeatureDataset":
print("true")
if desc['datasetType'] == "FeatureDataset":
arcpy.env.workspace = os.path.join(dirP, fd)
fdFCList =arcpy.ListFeatureClasses()
if fdFCList:
for fc in fdFCList:
fList.append([os.path.join(dirP, fd, fc)])
'''Yields:''
# T:\...\nhd FeatureDataset
# true
# ---------------------------------------------------------------------------
# ValueError Traceback (most recent call last)
Line 4: desc= (arcpy.da.Describe(fd))
ValueError: Object: Error in accessing describe
In short, it'll do the first one or two feature datasets, then it'll break somehow.
Sometimes it does just the first, sometimes it does the first two.
Has anyone encountered anything like this before?
Thanks!
Edit: It looks like it has to do with setting the environment. How do I fix this? It worked fine for feature datasets in GDBs.
Solved! Go to Solution.
I ended up just resetting the environment to the original directory after appending all the feature classes.
I ended up just resetting the environment to the original directory after appending all the feature classes.
Hi @AlfredBaldenweck ,
I encountered the same error message with you in my Python script that previously worked fine with the same code. Could you explain how to reset the environment within the script?
Thanks,
Donghee
Yeah of course. It's just doing this:
arcpy.env.workspace = 'path to your desired geodatabase'
Thank you for sharing the code.
I realized the error message was related to the arcpy environment from your solution. However, I also encountered an error message about the kernel in the code below:
arcpy.management.CreateFileGDB()
In my case, I was able to resolve the same error message by downgrading ArcGIS Pro's version from 3.2 to 3.1.
Appreciate your assistance!