This code only works when ArcCatalog is closed or the featureclass has never been opened by ArcCatalog. For other arcpy management functions this is not the case, but when ArcCatalog is open, I get the error in Sublime text2:

[Decode error - output not utf-8]

or in IDLE the error "feature class locked"

But when it is closed, it works fine.

for item in nfld_rrop:
    if item in ["test","PLANZ"]:   
        print item            this
        arcpy.DeleteField_management(fc, item)

Is there any way to stop this?

  • is the word 'this' supposed to be a comment on the line? if so use, '# this' or remove it from the thread
    – user681
    Jun 21 '15 at 16:40

When a feature class is open in arccatalog, arccatalog puts an exclusive schema lock on that. Furthermore Deleting a field using arcpy.DeleteField_management(fc, item), need schema lock too!

To solve this situation:

If your feature class is from personal or file GDB, simply click the top parent folder of geodatabase and press "F5". This releases the schema lock

enter image description here

If your feature class is from an enterprise geodatabase, disconnect the sde connection file.

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.