Schema lock error from script tool before script executes.

2687
3
Jump to solution
10-30-2012 07:50 PM
BrentBrock
New Contributor III
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 'ERROR 000601: Cannot delete C:\WorkSpace\table.dbf. May be locked by another application.' 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.

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:

http://forums.esri.com/thread.asp?c=93&f=1729&t=269523

http://forums.esri.com/thread.asp?c=93&f=1729&t=300027

I tried the work around and a few variants in the second thread but haven't found anything that works. Any ideas?

Brent Brock, Landscape Ecologist
Craighead Institute
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
BrentBrock
New Contributor III
I found the problem. In the tool, the output parameter was set to a 'file' data type.  I changed data type to 'table' and now it works.

Brent Brock, Landscape Ecologist
Craighead Institute

View solution in original post

0 Kudos
3 Replies
MathewCoyle
Frequent Contributor
This doesn't work?

if arcpy.Exists(your_output):
    arcpy.Delete_management(your_output)
0 Kudos
BrentBrock
New Contributor III
This doesn't work?

if arcpy.Exists(your_output):
    arcpy.Delete_management(your_output)


Nope.  That was the first thing I tried.  I also tried the following to try to get at this without going through arcpy:

import os
if os.path.exists(your_output):
    os.remove(your_output)


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.  I'm going to try deleting the tool GUI and starting from scratch.

Brent
0 Kudos
BrentBrock
New Contributor III
I found the problem. In the tool, the output parameter was set to a 'file' data type.  I changed data type to 'table' and now it works.

Brent Brock, Landscape Ecologist
Craighead Institute
0 Kudos