<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic File lock on file geodatabase when running arcpy in command line in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/file-lock-on-file-geodatabase-when-running-arcpy/m-p/1640413#M98009</link>
    <description>&lt;P&gt;Hi I am running a script in the command line with the hope of sending it to task scheduler at some point. I'm getting a lock error when I try to zip a file geodatabase. I don't get this error when I run the script directly within arcpro's notebook. Is there any solution for this and a explanation of why.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The line of code im using to zip the file geodatabase can be seen below&lt;/P&gt;&lt;P&gt;print('#Zipping file geodatabase to be sent to AGOL')&lt;BR /&gt;result = shutil.make_archive(r'ElectricDataToAGOL',format='zip',base_dir='ElectricDataToAGOL.gdb')&lt;BR /&gt;del result&lt;/P&gt;&lt;P&gt;This code works without any locks when I run it in a Arcpro notebook&lt;/P&gt;&lt;P&gt;The error message I get can be seen below&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\Scripts_and_Projects\Archive\Modules\ElectricDataToAGOL.py", line 75, in &amp;lt;module&amp;gt;&lt;BR /&gt;result = shutil.make_archive(r'ElectricDataToAGOL',format='zip',base_dir='ElectricDataToAGOL.gdb')&lt;BR /&gt;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\shutil.py", line 1165, in make_archive&lt;BR /&gt;filename = func(base_name, base_dir, **kwargs)&lt;BR /&gt;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\shutil.py", line 1046, in _make_zipfile&lt;BR /&gt;zf.write(path, arcname)&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\zipfile.py", line 1814, in write&lt;BR /&gt;with open(filename, "rb") as src, self.open(zinfo, 'w') as dest:&lt;BR /&gt;^^^^^^^^^^^^^^^^^^^^&lt;BR /&gt;PermissionError: [Errno 13] Permission denied: 'ElectricDataToAGOL.gdb\\_gdb.GIS-ENT-SQL1.11216.5248.sr.lock'&lt;/P&gt;</description>
    <pubDate>Fri, 08 Aug 2025 16:26:00 GMT</pubDate>
    <dc:creator>ChaceCarpenter</dc:creator>
    <dc:date>2025-08-08T16:26:00Z</dc:date>
    <item>
      <title>File lock on file geodatabase when running arcpy in command line</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/file-lock-on-file-geodatabase-when-running-arcpy/m-p/1640413#M98009</link>
      <description>&lt;P&gt;Hi I am running a script in the command line with the hope of sending it to task scheduler at some point. I'm getting a lock error when I try to zip a file geodatabase. I don't get this error when I run the script directly within arcpro's notebook. Is there any solution for this and a explanation of why.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The line of code im using to zip the file geodatabase can be seen below&lt;/P&gt;&lt;P&gt;print('#Zipping file geodatabase to be sent to AGOL')&lt;BR /&gt;result = shutil.make_archive(r'ElectricDataToAGOL',format='zip',base_dir='ElectricDataToAGOL.gdb')&lt;BR /&gt;del result&lt;/P&gt;&lt;P&gt;This code works without any locks when I run it in a Arcpro notebook&lt;/P&gt;&lt;P&gt;The error message I get can be seen below&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\Scripts_and_Projects\Archive\Modules\ElectricDataToAGOL.py", line 75, in &amp;lt;module&amp;gt;&lt;BR /&gt;result = shutil.make_archive(r'ElectricDataToAGOL',format='zip',base_dir='ElectricDataToAGOL.gdb')&lt;BR /&gt;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\shutil.py", line 1165, in make_archive&lt;BR /&gt;filename = func(base_name, base_dir, **kwargs)&lt;BR /&gt;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\shutil.py", line 1046, in _make_zipfile&lt;BR /&gt;zf.write(path, arcname)&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\zipfile.py", line 1814, in write&lt;BR /&gt;with open(filename, "rb") as src, self.open(zinfo, 'w') as dest:&lt;BR /&gt;^^^^^^^^^^^^^^^^^^^^&lt;BR /&gt;PermissionError: [Errno 13] Permission denied: 'ElectricDataToAGOL.gdb\\_gdb.GIS-ENT-SQL1.11216.5248.sr.lock'&lt;/P&gt;</description>
      <pubDate>Fri, 08 Aug 2025 16:26:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/file-lock-on-file-geodatabase-when-running-arcpy/m-p/1640413#M98009</guid>
      <dc:creator>ChaceCarpenter</dc:creator>
      <dc:date>2025-08-08T16:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: File lock on file geodatabase when running arcpy in command line</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/file-lock-on-file-geodatabase-when-running-arcpy/m-p/1640548#M98026</link>
      <description>&lt;P&gt;The solution is to clear the cache of the workspace by using arcpy.management.ClearWorkspaceCache()&lt;/P&gt;</description>
      <pubDate>Fri, 08 Aug 2025 20:19:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/file-lock-on-file-geodatabase-when-running-arcpy/m-p/1640548#M98026</guid>
      <dc:creator>ChaceCarpenter</dc:creator>
      <dc:date>2025-08-08T20:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: File lock on file geodatabase when running arcpy in command line</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/file-lock-on-file-geodatabase-when-running-arcpy/m-p/1678477#M101281</link>
      <description>&lt;P&gt;`&lt;SPAN&gt;arcpy.management.ClearWorkspaceCache()&lt;/SPAN&gt;` appears to do the trick for a similar stack trace coming from a geoprocessing service.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jan 2026 21:32:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/file-lock-on-file-geodatabase-when-running-arcpy/m-p/1678477#M101281</guid>
      <dc:creator>DanNarsavage_IDWR</dc:creator>
      <dc:date>2026-01-16T21:32:49Z</dc:date>
    </item>
  </channel>
</rss>

