I have a function where I am trying to rename a geodatabase, both os.rename and arcpy.Rename_management() work in the Python window but not in the script when run as a tool through ArcCatalog.

Traceback (most recent call last):
  File "C:\PecosFieldTools\ProTools_v1.2\PhaseDeliverables\phase.py", line 562, in <module>
    arcpy.Rename_management(in_data=newGdb, out_data=phaseGdb, data_type="Workspace")
  File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\management.py", line 4528, in Rename
    raise e
ExecuteError: ERROR 999999: Error executing function.
Failed to execute (Rename).

Failed to execute (Phase)

I think this may be a permission issue but I am admin running this on my own machine. When I wrap in try and except I get these error

[Errno 13] Permission denied: u'C:\\\\Projects\\\\PhaseMasters\\\\HasData\\\\1810227C\\\\Master\\\\PHASE_DELIVERABLES\\\\DB13635_AF2136641_AP_00_X04.gdb\\\\EQ_AIR_COOLED_EXCHANGER_POLY.LAPTOP-3B9ORV48.16500.16420.sr.lock'")

But when I open the file geodatabase I do not see any locks and I am deleting all my cursors. Is there a way to await the locks to be removed with Python?

Here is where I am running the tool from:
enter image description here

  • 1
    If you use the Catalog window within ArcMap, then you shouldn't have lock issues, but if you run ArcCatalog and anything else, then there will be conflicts.
    – Vince
    Feb 22, 2019 at 14:31
  • That is what I mean, running the code from the catalog pane of ArcMap the tool fails but the code runs when pasted into the python Window. I turned off the background processing and no change. I don't know enough about what the python script tool does that would cause the code to work in the window but not in a tool? Feb 22, 2019 at 18:14
  • 1
    I stopped using ArcCatalog when the Catalog window was added to ArcMap, so I wouldn't have lock issues. It doesn't seem counter-intuitive that you can't change the directory name on a Windows volume while that directory is open in another process.
    – Vince
    Feb 22, 2019 at 18:33
  • I am running the tool from inside arcmap. I am not sure why the directory would be in use by another process so I don't understand. Feb 22, 2019 at 19:18
  • If you quit out of arcmap completely, can you rename the fgdb folder successfully? Feb 22, 2019 at 21:40

1 Answer 1


I used arcpy.Compact_management before copying and renaming the geodatabase, tool now works.

copyDict = {filePath1:filePath2,filePath3:filePath4}
for k,v in copyDict.iteritems():
    arcpy.AddMessage("Copy Success")
  • It would be helpful if you accept this answer
    – Padmanabha
    Jul 1, 2023 at 12:55
  • If I remember correctly this ended up being a big issue with I think it was ArcGIS Pro 1.4, ESRI gave us bug fix release and then wrapped the fix into 1.5, this is the memory I have but it was about 5 years ago. Thanks for your contribution. Jul 2, 2023 at 13:43

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.