2

I am writing an arcpy script and testing against a file Geodatabase. I can open the Geodatabase workspace and iterate through the "ListFeatrueClasses".

However if I try to "ListFields" I get an IO Error.

I have already tried changing the workspace directory in various ways as suggested by other posts with no success. I also made sure the file Geodatabase is fully accessible and currently its on my local drive.

This is the error:

Traceback (most recent call last): File
"C:\Users\username\Source\Repos\Python-proj1\Python-proj1\openprimegeo.
py", line 29, in
fields = arcpy.ListFields(fc1) File "C:\Program Files (x86) \ArcGIS\Desktop10.5\ArcPy\arcpy__init__.py", line 1138, in ListFields
return gp.listFields(dataset, wild_card, field_type) File "C:\Program Files
(x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\geoprocessing_bas e.py", line 346, in listFields
self._gp.ListFields(*gp_fixargs(args, True))) IOError: "Test_Polygon" does not exist

C:\Python27\ArcGIS10.5>


Script:

import arcpy
from arcpy import env

arcpy.env.workspace = "C:/Users/username/Downloads/prime/Prime_Template.gdb/Prime_Template.gdb"

print "starting..."

featureclasses = arcpy.ListFeatureClasses()

for fc in featureclasses:
    print fc

fcList = arcpy.ListFeatureClasses()
print fcList
print "\n\n"
print "List Feature Class fields..."
print "\n\n"
for fc1 in fcList:
    fields = arcpy.ListFields(fc1)
    for field in fields:
        print "{0} is a type of {1} with a length of {2}".format(field.name, field.type, field.length)
  • Thank you for your comments but it actually never gets that far. I have also actually commented out everything starting with "for field in fields:" and after to be sure. I posted it here without the comment tag so everyone can see everything – Xavier Feb 23 '18 at 14:30
  • Yes, it does open in ArcMap and I am able to edit the data in the fields. But I will try the other suggestions as well. – Xavier Feb 23 '18 at 14:51
  • I made a new geodatabase and copied the feature class and it worked. Thank you! -- I do not know how to mark this questoin as answered and supply you with the credit – Xavier Feb 23 '18 at 15:19
  • Ah, glad we nailed it down! I've posted an answer you can accept, so we could close the thread! – Alex Tereshenkov Feb 23 '18 at 17:07
  • 2
    Please don't add "thank you" as an answer. Instead, accept the answer that you found most helpful. - From Review – Dan C Feb 23 '18 at 17:32
1

If you are not able to read the feature classes using ArcMap connecting to this geodatabase, it may be corrupted.

If you are able, try creating a new file geodatabase and copy the feature classes into the newly created one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.