I'm writing a python script, I've got an mxd and its workspace is a geodatabase file with all the files I need into. The problem I'm encountering in testing and writing code is that, despite of the command:


all the files contained in geodatabase fail to overwrite. There's a way to work around this?

  • In ArcMap, did you check the "Overwrite the outputs of geoprocessing operations" in Geoprocessing>Geoprocessing Options?
    – Baltok
    Commented Oct 4, 2012 at 15:25
  • yes, I did. But didn't work. Commented Oct 4, 2012 at 15:43
  • 3
    Are you aware of any schema locks on your data? That can prevent overwriting as well. File and Personal Geodatabases are particularly sensitive to this, because if one feature class has a lock, it locks the whole geodatabase.
    – Baltok
    Commented Oct 4, 2012 at 16:03
  • 2
    When you say that "all the files contained in the geodatabase fail to overwrite", do you mean the script fails or it completes but just does not overwrite the featureclasses which it should? Commented Oct 4, 2012 at 16:20
  • try to run your code from a python IDE like PyScripter, then close ArcMap.
    – geogeek
    Commented Oct 4, 2012 at 20:10

3 Answers 3


If I recall correctly there are certain situations for which overwriteOutput won't work. In that case use the following code prior to writing out new files:

if arcpy.Exists(fileInQuestion):

Make sure the file geodatabase is not compressed i.e., read only.


I was also having this problem and the comment about the schema locks really helped. If you have an mxd with that feature class on it, it locks that feature class so it cannot be deleted. If you just exit the mxd that contains that feature class and run the same overwrite code, it seems to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.