Skip to main content
deleted 25 characters in body; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Can't file Cannot find feature class after adding a new field in arcpyArcPy?

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()[0]
arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
    for row in cursor:
        print(row[0]) # just simple printing of Object ID
        cursor.updateRow(row)

How could I overcome this problem? Thank you in advance.

Can't file feature class after adding a new field in arcpy

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()[0]
arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
    for row in cursor:
        print(row[0]) # just simple printing of Object ID
        cursor.updateRow(row)

How could I overcome this problem? Thank you in advance.

Cannot find feature class after adding new field in ArcPy?

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()[0]
arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
    for row in cursor:
        print(row[0]) # just simple printing of Object ID
        cursor.updateRow(row)

How could I overcome this problem?

added 101 characters in body
Source Link
Matt_Geo
  • 1k
  • 1
  • 11
  • 28

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:

What it says it cannot openThe log of the file "main_points" thatproblem says is in the database.:

builtins.RuntimeError: cannot open 'main_points'

However if I remove the line of adding field:

arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)

It runs theThe script runs smoothly.

(And the same problem pops up ifPS: If I tryreplace the line of adding field to remove adelete 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()[0]
arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
    for row in cursor:
        print(row[0]) # just simple printing of Object ID
        cursor.updateRow(row)

How could I overcome this problem? Thank you in advance.

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:

What it says it cannot open the file "main_points" that is in the database. However if I remove the line of adding field:

arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)

It runs the script smoothly.

(And the same problem pops up if I try to remove a field using: "arcpy.DeleteField_management")

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()[0]
arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
    for row in cursor:
        print(row[0]) # just simple printing of Object ID
        cursor.updateRow(row)

How could I overcome this problem? Thank you in advance.

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()[0]
arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
    for row in cursor:
        print(row[0]) # just simple printing of Object ID
        cursor.updateRow(row)

How could I overcome this problem? Thank you in advance.

added 101 characters in body
Source Link
Matt_Geo
  • 1k
  • 1
  • 11
  • 28

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:

What it says it cannot open the file "main_points" that is in the database. However if I remove the line of adding field:

arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)

It runs the script smoothly.

(And the same problem pops up if I try to remove a field using: "arcpy.DeleteField_management")

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()[0]
arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
    for row in cursor:
        print(row[0]) # just simple printing of Object ID
        cursor.updateRow(row)

How could I overcome this problem? Thank you in advance.

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:

What it says it cannot open the file "main_points" that is in the database. However if I remove the line of adding field:

arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)

It runs the script smoothly.

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()[0]
arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
    for row in cursor:
        print(row[0]) # just simple printing of Object ID
        cursor.updateRow(row)

How could I overcome this problem? Thank you in advance.

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:

What it says it cannot open the file "main_points" that is in the database. However if I remove the line of adding field:

arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)

It runs the script smoothly.

(And the same problem pops up if I try to remove a field using: "arcpy.DeleteField_management")

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()[0]
arcpy.AddField_management(main_points, "tag_id", "SHORT", 10)
with arcpy.da.UpdateCursor(main_points, "*" ) as cursor:
    for row in cursor:
        print(row[0]) # just simple printing of Object ID
        cursor.updateRow(row)

How could I overcome this problem? Thank you in advance.

Source Link
Matt_Geo
  • 1k
  • 1
  • 11
  • 28
Loading