<?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 Schema lock error from script tool before script executes. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/schema-lock-error-from-script-tool-before-script/m-p/235436#M18298</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've run into yet another annoying schema lock problem. I have a python script run from a toolbox script tool that creates a stand alone table as output. It works fine except the tool will not overwrite outputs despite having the overwrite geoprocessing outputs option checked. The script throws &lt;/SPAN&gt;&lt;SPAN style="color:&amp;quot;#0000CD&amp;quot;;"&gt;'ERROR 000601: Cannot delete C:\WorkSpace\table.dbf. May be locked by another application.'&lt;/SPAN&gt;&lt;SPAN&gt; However, there is no schema lock since the file can be easily deleted from ArcCatalog or the os. Also, when you set the output of the tool to an existing file, you get the usual warning about overwriting the output and the yellow warning triangle appears next to the parameter.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried the usual workarounds like setting the arcpy.env.overwriteOutput = 1, checking for the existence of the file and deleting from within the script, etc. But what I have discovered is the error is occuring before any of the script is executed. So it is a problem with the tool validation. I found a couple threads in the archive that seem to deal with this same problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://forums.esri.com/thread.asp?c=93&amp;amp;f=1729&amp;amp;t=269523" rel="nofollow" target="_blank"&gt;http://forums.esri.com/thread.asp?c=93&amp;amp;f=1729&amp;amp;t=269523&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://forums.esri.com/thread.asp?c=93&amp;amp;f=1729&amp;amp;t=300027&amp;lt;br/&amp;gt;" rel="nofollow" target="_blank"&gt;http://forums.esri.com/thread.asp?c=93&amp;amp;f=1729&amp;amp;t=300027&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the work around and a few variants in the second thread but haven't found anything that works. Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brent Brock, Landscape Ecologist&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Craighead Institute&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Oct 2012 02:50:17 GMT</pubDate>
    <dc:creator>BrentBrock</dc:creator>
    <dc:date>2012-10-31T02:50:17Z</dc:date>
    <item>
      <title>Schema lock error from script tool before script executes.</title>
      <link>https://community.esri.com/t5/python-questions/schema-lock-error-from-script-tool-before-script/m-p/235436#M18298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've run into yet another annoying schema lock problem. I have a python script run from a toolbox script tool that creates a stand alone table as output. It works fine except the tool will not overwrite outputs despite having the overwrite geoprocessing outputs option checked. The script throws &lt;/SPAN&gt;&lt;SPAN style="color:&amp;quot;#0000CD&amp;quot;;"&gt;'ERROR 000601: Cannot delete C:\WorkSpace\table.dbf. May be locked by another application.'&lt;/SPAN&gt;&lt;SPAN&gt; However, there is no schema lock since the file can be easily deleted from ArcCatalog or the os. Also, when you set the output of the tool to an existing file, you get the usual warning about overwriting the output and the yellow warning triangle appears next to the parameter.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried the usual workarounds like setting the arcpy.env.overwriteOutput = 1, checking for the existence of the file and deleting from within the script, etc. But what I have discovered is the error is occuring before any of the script is executed. So it is a problem with the tool validation. I found a couple threads in the archive that seem to deal with this same problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://forums.esri.com/thread.asp?c=93&amp;amp;f=1729&amp;amp;t=269523" rel="nofollow" target="_blank"&gt;http://forums.esri.com/thread.asp?c=93&amp;amp;f=1729&amp;amp;t=269523&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://forums.esri.com/thread.asp?c=93&amp;amp;f=1729&amp;amp;t=300027&amp;lt;br/&amp;gt;" rel="nofollow" target="_blank"&gt;http://forums.esri.com/thread.asp?c=93&amp;amp;f=1729&amp;amp;t=300027&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the work around and a few variants in the second thread but haven't found anything that works. Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brent Brock, Landscape Ecologist&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Craighead Institute&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 02:50:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/schema-lock-error-from-script-tool-before-script/m-p/235436#M18298</guid>
      <dc:creator>BrentBrock</dc:creator>
      <dc:date>2012-10-31T02:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Schema lock error from script tool before script executes.</title>
      <link>https://community.esri.com/t5/python-questions/schema-lock-error-from-script-tool-before-script/m-p/235437#M18299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This doesn't work?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if arcpy.Exists(your_output):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(your_output)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:52:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/schema-lock-error-from-script-tool-before-script/m-p/235437#M18299</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T11:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Schema lock error from script tool before script executes.</title>
      <link>https://community.esri.com/t5/python-questions/schema-lock-error-from-script-tool-before-script/m-p/235438#M18300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This doesn't work?&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if arcpy.Exists(your_output):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(your_output)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nope.&amp;nbsp; That was the first thing I tried.&amp;nbsp; I also tried the following to try to get at this without going through arcpy:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
if os.path.exists(your_output):
&amp;nbsp;&amp;nbsp;&amp;nbsp; os.remove(your_output)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that the error is thrown before the script even executes so there is nothing I can add to the script to fix it. Seems to be a validation issue.&amp;nbsp; I'm going to try deleting the tool GUI and starting from scratch.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brent&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:52:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/schema-lock-error-from-script-tool-before-script/m-p/235438#M18300</guid>
      <dc:creator>BrentBrock</dc:creator>
      <dc:date>2021-12-11T11:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Schema lock error from script tool before script executes.</title>
      <link>https://community.esri.com/t5/python-questions/schema-lock-error-from-script-tool-before-script/m-p/235439#M18301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I found the problem. In the tool, the output parameter was set to a 'file' data type.&amp;nbsp; I changed data type to 'table' and now it works. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brent Brock, Landscape Ecologist&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Craighead Institute&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 15:29:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/schema-lock-error-from-script-tool-before-script/m-p/235439#M18301</guid>
      <dc:creator>BrentBrock</dc:creator>
      <dc:date>2012-10-31T15:29:41Z</dc:date>
    </item>
  </channel>
</rss>

