<?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 Cannot overwrite feature class file in gdb while occupied by ArcGIS Pro in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cannot-overwrite-feature-class-file-in-gdb-while/m-p/1243193#M66329</link>
    <description>&lt;P&gt;I wrote the following piece of code that loops over a map features and buffer them. new buffer layers are saved to a different gdp with in this project.&lt;/P&gt;&lt;P&gt;If I run the code from IDLE while that project is not open in ArcGIS than I can run it many times and the files in the results.gdb gets overwrite with no issues. However, if I try to run the code from IDLE while that same project is open in ArcGIS and if the buffer files to be created by that code already exists (same file name) in the&amp;nbsp;results.gdb (output path; destination) them I get and error that the buffer method failed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;ERROR 000258: Output C:\\Users\\User\\Desktop\\PythonClassHWEx\\L8_HomeWore\\Ex8\\results.gdb\routes1_buffer already exists
Failed to execute (Buffer).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I try to add an IF-BLOCK to check if the file by that name already exists and then delete it before saving new buffer layer with the same name,&amp;nbsp;&lt;SPAN&gt;I get an error that the schema is locked:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Error ERROR 000464: Cannot get exclusive schema lock.  Either being edited or in use by another application or service.
Failed to execute (Delete).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm trying to execute:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy.md


#function to captue ArcPro project file elements
#and create a pre-defined buffer area around them

#init variables
arcpy.env.workspace = r"C:\\Users\\User\\Desktop\\PythonClassHWEx\\L8_HomeWore\\Ex8\\demo.gdb"
arcpy.env.overwriteOutput = True

featureclasses = arcpy.ListFeatureClasses()
bufferDistance = '850'

try:
  
  for fc in featureclasses:
    output = r"C:\\Users\\User\\Desktop\\PythonClassHWEx\\L8_HomeWore\\Ex8\\results.gdb\\"+fc+'_buffer'
    arcpy.Buffer_analysis(in_features=fc, out_feature_class=output, buffer_distance_or_field=bufferDistance+" Meters", line_side="FULL", line_end_type="ROUND", dissolve_option="NONE", dissolve_field=[], method="PLANAR")
    

  
except Exception as e:
    print("Error " + e.args[0])
    
print('Done!')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code run just fine if using the build-in ArcGIS Pro python window&amp;nbsp; and it overwrites whatever file with same name(s) are in the output path gdb. As many time as I execute it. No errors.&lt;/P&gt;&lt;P&gt;Any direction or help is highly appreciated.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Dec 2022 08:09:23 GMT</pubDate>
    <dc:creator>BarakGarty</dc:creator>
    <dc:date>2022-12-22T08:09:23Z</dc:date>
    <item>
      <title>Cannot overwrite feature class file in gdb while occupied by ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/cannot-overwrite-feature-class-file-in-gdb-while/m-p/1243193#M66329</link>
      <description>&lt;P&gt;I wrote the following piece of code that loops over a map features and buffer them. new buffer layers are saved to a different gdp with in this project.&lt;/P&gt;&lt;P&gt;If I run the code from IDLE while that project is not open in ArcGIS than I can run it many times and the files in the results.gdb gets overwrite with no issues. However, if I try to run the code from IDLE while that same project is open in ArcGIS and if the buffer files to be created by that code already exists (same file name) in the&amp;nbsp;results.gdb (output path; destination) them I get and error that the buffer method failed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;ERROR 000258: Output C:\\Users\\User\\Desktop\\PythonClassHWEx\\L8_HomeWore\\Ex8\\results.gdb\routes1_buffer already exists
Failed to execute (Buffer).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I try to add an IF-BLOCK to check if the file by that name already exists and then delete it before saving new buffer layer with the same name,&amp;nbsp;&lt;SPAN&gt;I get an error that the schema is locked:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Error ERROR 000464: Cannot get exclusive schema lock.  Either being edited or in use by another application or service.
Failed to execute (Delete).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm trying to execute:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy.md


#function to captue ArcPro project file elements
#and create a pre-defined buffer area around them

#init variables
arcpy.env.workspace = r"C:\\Users\\User\\Desktop\\PythonClassHWEx\\L8_HomeWore\\Ex8\\demo.gdb"
arcpy.env.overwriteOutput = True

featureclasses = arcpy.ListFeatureClasses()
bufferDistance = '850'

try:
  
  for fc in featureclasses:
    output = r"C:\\Users\\User\\Desktop\\PythonClassHWEx\\L8_HomeWore\\Ex8\\results.gdb\\"+fc+'_buffer'
    arcpy.Buffer_analysis(in_features=fc, out_feature_class=output, buffer_distance_or_field=bufferDistance+" Meters", line_side="FULL", line_end_type="ROUND", dissolve_option="NONE", dissolve_field=[], method="PLANAR")
    

  
except Exception as e:
    print("Error " + e.args[0])
    
print('Done!')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code run just fine if using the build-in ArcGIS Pro python window&amp;nbsp; and it overwrites whatever file with same name(s) are in the output path gdb. As many time as I execute it. No errors.&lt;/P&gt;&lt;P&gt;Any direction or help is highly appreciated.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 08:09:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-overwrite-feature-class-file-in-gdb-while/m-p/1243193#M66329</guid>
      <dc:creator>BarakGarty</dc:creator>
      <dc:date>2022-12-22T08:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot overwrite feature class file in gdb while occupied by ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/cannot-overwrite-feature-class-file-in-gdb-while/m-p/1243333#M66334</link>
      <description>&lt;P&gt;Can't tell what else your complete script is doing, but file GDB's do not support concurrent writing and if you have the layers loaded in the TOC, it won't overwrite and fail if ran from outside of the Pro env (python window).&lt;/P&gt;&lt;P&gt;It works in the Pro window because it is using the lock/ env that has the rights/lock to that fgdb.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 15:39:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-overwrite-feature-class-file-in-gdb-while/m-p/1243333#M66334</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-12-22T15:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot overwrite feature class file in gdb while occupied by ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/cannot-overwrite-feature-class-file-in-gdb-while/m-p/1243366#M66337</link>
      <description>&lt;P&gt;What is written is all the code does. loop over the feature class in the demo.gdb and creates a buffer for each and saves it to results.gdb.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that there no solution for that problem; if the file I try to o\w from an external IDE is occupied by Pro env the code run will fail with that error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a workaround that is not as neat as I wanted, by adding the current pc EPOCH time as a suffix to the created buffer file, thus it retains a unique name and works if I run it from IDLE while the project is loaded to Pro env.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your clarification tho. Much appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 17:16:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-overwrite-feature-class-file-in-gdb-while/m-p/1243366#M66337</guid>
      <dc:creator>BarakGarty</dc:creator>
      <dc:date>2022-12-22T17:16:28Z</dc:date>
    </item>
  </channel>
</rss>

