Error: Cannot get exclusive schema lock

5413
3
01-16-2013 09:37 AM
EmilyAgar1
New Contributor
Hello
I am getting an error 000464: Cannot get exclusive schema lock. Either being edited or in use by another application. Failed to execute deletefield

import arcpy

arcpy.env.workspace = "W:\ENG\Geomatics\GIS\Eastern Region Geodatabase.gdb"

arcpy.geoprocessing.env.overwriteOutput = True

arcpy.Buffer_analysis("ER_5_Year_Program", "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Program_Buff", "350 METERS", "FULL", "FLAT", "NONE")

targetFeatures = "W:\ENG\Geomatics\GIS\Eastern Region Geodatabase.gdb\ER_Culverts"
joinFeatures = "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Program_Buff"
  
outfc = "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Culvert_5YCP.shp"
  
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable("ER_Culverts")
fieldmappings.addTable("W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Program_Buff.shp")

GWPFieldIndex = fieldmappings.findFieldMapIndex("GWP")
fieldmap = fieldmappings.getFieldMap(GWPFieldIndex)
field = fieldmap.outputField
 
field.name = "WP"
field.length = "100"
fieldmap.outputField = field
 
fieldmap.mergeRule = "Join"
fieldmap.joinDelimiter = ","
fieldmappings.replaceFieldMap(GWPFieldIndex, fieldmap)

arcpy.SpatialJoin_analysis("ER_Culverts", "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Program_Buff.shp", outfc,"JOIN_ONE_TO_ONE","KEEP_COMMON", fieldmappings)

arcpy.ResetEnvironments()
arcpy.env.workspace = "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities"

arcpy.Select_analysis("Culvert_5YCP.shp", "Culverts_to_Review", '''"STD_CND" in ('Poor', 'Very Poor', 'Unknown', '')''')

arcpy.DeleteField_management("Culverts_to_Review", "COMMENT;YEAR;Join_Count;TARGET_FID;Shape_Le_1;BUFF_DIST")

arcpy.Delete_management("Culvert_5YCP.shp")

arcpy.Delete_management("Program_Buff.shp")


The culverts to review.shp is in a file on our network drive and not in a gdb, no one else is accessing it but me. Any ideas as to why I would be getting this error?
Thanks
Tags (2)
0 Kudos
3 Replies
MathewCoyle
Frequent Contributor
This looks like you are making a shapefile? You may need to add .shp, though it really shouldn't make a difference. Do you have a previous version with the same name open in another process/application?

Also, you should be using a list for the fields to delete.
['COMMENT','YEAR','Join_Count','TARGET_FID','Shape_Le_1','BUFF_DIST']


Also, add the raw string tag to your paths to avoid problems.
Eg.
r"W:\ENG\Geomatics\GIS\Eastern Region Geodatabase.gdb"
0 Kudos
EmilyAgar1
New Contributor
Awesome thank you!! I made both those changes and it runs error free!!

One more quick question though, is there a way to bypass the interface that pops up when running a script where you would typically have user inputs? I click on the script in the toolbox then the interface pops up and says there are no input parameters and I have to hit ok on it also then it will run. Its not a big deal but it would be nice if it just runs when you click on the script.
0 Kudos
MathewCoyle
Frequent Contributor
In 10.1 you can create a python add-in that is able to bypass this I believe. In 10.0 I'm not sure if you can without using ArcObjects.
0 Kudos