I'm struggling with a very basic problem. it seems though, it's a problem with arcpy itself.
I'm running the following code and it's give me a problem in the line of:
with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
The log of the problem says is:
builtins.RuntimeError: cannot open 'main_points'
However if I remove the line of adding field:
arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
The script runs smoothly.
(PS: If I replace the line of adding field to delete field using "arcpy.DeleteField_management", the same problem happens giving me the same log error)
Here is my whole code:
import arcpy WorkingDirectory = r"C:\Users\me\Documents" arcpy.env.workspace = WorkingDirectory arcpy.env.overwriteOutput=True arcpy.CreateFileGDB_management(WorkingDirectory, "project.gdb") arcpy.FeatureClassToGeodatabase_conversion(["main_points.shp"], "project.gdb") arcpy.env.workspace = "project.gdb" main_points = arcpy.ListFeatureClasses() arcpy.AddField_management(main_points, "tag_id", "SHORT", 10) with arcpy.da.UpdateCursor(main_points, "*" ) as cursor: for row in cursor: print(row) # just simple printing of Object ID cursor.updateRow(row)
How could I overcome this problem?