Geographic Information Systems Asked by NW_Photo_Laureate on February 1, 2021
I am having an issue with schema locks while working on feature classes within a file geodatabase in ArcMap. There have been similar posts to mine (Avoiding exclusive schema lock error with ArcPy?). However, I am not working in an ArcSDE environment. I am running a Python script through the command line (Conda thru Windows if pertinent):
>>>python add_field_script.py
which calls arcpy functions WHILE ArcMap is open.
arcpy.DeleteField_management(fp_feature, ['field1', 'field2'])
I get this error (in command line console):
File "field_mappings_config.py", line 42, in <module>
arcpy.Delete_management(fc)
File "C:Program Files (x86)ArcGISDesktop10.6arcpyarcpymanagement.py", line 4363, in Delete
raise e
arcgisscripting.ExecuteError: ERROR 000464: Cannot get exclusive schema lock. Either being edited or in use by another application.
Failed to execute (Delete).
My attrocious work-around is basically turn off and turn on again. I CLOSE ArcMap and rerun. Removing the fp_feature in the current map and/or collapsing feature dataset in ArCatalog without shutting off does not remove the Schema Lock.
Any ideas?
ArcMap is notorious for maintaining locks on datasets that have been removed from the map. As far as I'm aware, the only way to force ArcMap to release locks is to close ArcMap completely (even then, it will sometimes fail to close, and remain running in the background with locks still in use - Task Manager is then required to kill it).
If it suits your workflow, you should be able to do this by running the Python from within the ArcMap Python console (instead of on the command line or in an IDE). I've just tried this on a feature class for which there was a layer in the map and it worked fine.
As a subsequent comment stated, this way it runs in the same process (ie, ArcMap) and therefore there is no contention for locks.
Alternatively, you can also run Python within a Model Builder model. You can use the "Calculate Value" item in a model to run a block of Python code, even if you're not interested in calculating a value.
Answered by Son of a Beach on February 1, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP