2

I have an existing script that copies a geodatabase to another location and renames it. It uses arcpy and os libraries to do it.

copy_from = r"C:\test.gdb" copy_to = r"D:\test.gdb" rename_to = r"D:\test_renamed.gdb" arcpy.env.overwriteoutput = True arcpy.Copy_management(copy_from, copy_to) os.rename(copy_to, rename_to) 

However, while renaming I am getting PermissionError: [WinError 5] Access is denied. I have verified that the user running the script has full access. I am able to temporarily fix the issue by using os.copytree instead of the arcpy function but I don't know why it is giving that error.

I have tried running Copy_management(copy_from, rename_to) as well but that gives a 000260: Failed to copy error.

EDIT:

System Specifications

Hardware - Intel Xeon 6248R, 128 GB RAM

OS - Windows Server 2019

Python Version - 2.7.18

2
  • Based on the version of python I assume you are running ArcMap, not ArcPro? My only suggestion is try running your script on another machine that is not running a server version of windows? Commented Nov 4, 2024 at 10:43
  • 1
    @Hornbydd Yes. For some reason, it is working on another (QA) server where the same script is deployed Commented Nov 11, 2024 at 6:07

1 Answer 1

2

Do not use the OS module to rename the geodatabase, use the rename tool instead. You are getting file locking occurring as you have accessed the geodatabase via arcpy.

5
  • I tried this too but it is throwing - ERROR 999999 - Error executing function. General function failure Commented Oct 30, 2024 at 6:40
  • That would indicate the source of your problem lies elsewhere and without further details will be impossible to solve. Commented Oct 30, 2024 at 14:13
  • Could you indicate what kind of problem it might be? Commented Nov 3, 2024 at 10:21
  • Not really there is not enough detail in your question. You say nothing about your system setup for a start. Edit your question and add that. Commented Nov 3, 2024 at 23:52
  • Sure. I have added them Commented Nov 4, 2024 at 3:21

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.