4

I wrote a Python script that produces several output features layers in separate .gdb's. As I am testing and modifying my code, I generally go into arcCatalog, find the .gdb under which the feature sits, and delete that feature from the .gdb (leaving the .gdb intact) before rerunning my script. This works fine for all of the feature layers except one. I get a schema lock error because the "file is open in a Python script." I literally have to close my Python IDE (Spyder running from Anaconda) and then go back and delete the feature from ArcCatalog. Any reasons why this is happening and suggestions on how I can resolve it?

  • 1
    Are you using background geoprocessing for your script? This can cause strange lock issues with fgdbs, maybe not like yours. – danak Aug 29 '18 at 16:27
  • I don't think so (not by design). How can I check? – gwydion93 Aug 29 '18 at 16:30
  • 1
    Question for clarification: Is the Schema Lock always on the last .gdb in your script? -- If that is the case you could make a "junk.gbd" and point your script at that for the last iteration and make this issue moot. -- If this works I'll change my comment into an answer. – user23715 Aug 29 '18 at 16:31
  • Hmmm, I'll try that and see. – gwydion93 Aug 29 '18 at 16:32
  • For future reference, since it seems you got a real answer, check your Geoprocessing options in ArcMap. There is a checkbox/toggle for enabling background processing. – danak Aug 29 '18 at 23:26
3

Looks like this general type problem has been around since forever.

Remove Lock on Feature Class

^That answer has a bit of code to add to your block that seems to work for Schema and Read Locks.

The last solution (as of 8-29-2018) over here on the ESRI Community at GeoNet says essentially what I suggested in my comment - to make scratch or junk .gdb to absorb the bug in the system. Trouble Removing Schema Lock after arcpy

And yes, it does seem to be a bug with no active intention of getting it fixed because, well... ESRI, and there are a few mildly annoying work-arounds. It's even been officially classed as a "bug".
Bug BUG-000086232

This is something that was proposed in February of 2011 to enhance the experience using Python in a geospatial environment. With no action so far we can expect there never to be. But never is a long time so, if you're young enough, you might be surprised at a software fix one day.

Expose Schema Lock Removal to Python

  • This was exactly the answer I was looking for! Thanks. I'll try the simple fix with the junk.gdb first. – gwydion93 Aug 29 '18 at 17:16

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.