AnsweredAssumed Answered

Understanding "cannot acquire a lock" in systems with limited access

Question asked by emucaki on Oct 9, 2020

I've written code which imports data from a file and creates a shape file, then uses "arcpy.Project_management" to create a second shape file with a specific spatial reference (an abbreviated version of the code is provided below; there are downstream steps after this point, but I am not going to get into specifics as it is not pertinent).

 

On my local system, everything works fine. However I have recently been using ArcMap on sensitive data that can only be accessed in an external system that is "locked down", where permissions are highly restricted. Now when the program reaches the "arcpy.Project_management" step:

> "arcpy.Project_management(newfcName, newfcNameProject, out_coordinate_system)"

 

I get two "cannot acquire lock" messages in a row, and a failure to execute message that kills the program:

"Error 999999: Error Executing Function.

Cannot acquire a lock.

Cannot acquire a lock.

Failed to execute (Project)"

 

Any ideas on why this is happening, I would be thankful. Note that this problem only occurs if running python within the ArcMap GUI. If run on the Python IDLE, the program runs without issue. 

 

And here's an abbreviated version of the code below:

 

import arcpy

 

outpath = r"C:/PATH/TO/OUTFOLDER/"

dataFile = "C:/PATH/TO/INPUT/input.csv"

arcpy.env.overwriteOutput=True
arcpy.env.workspace= outpath

 

newfcName = "OriginalData.shp"
newfcNameProject = "ProjectedData.shp"

 

# Shapefile with the coordinate system of the coordinate data within input
projectedexample = "ExampleData-in-Input-Coordinate-Format.prj"

# creating table to be filled
newfc = arcpy.CreateFeatureclass_management(outpath, newfcName, "POINT", "", "", "", projectedexample)
arcpy.AddField_management(newfc, "X", "FLOAT", field_length = 50)
arcpy.AddField_management(newfc, "Y", "FLOAT", field_length = 50)
arcpy.AddField_management(newfc, "Data", "FLOAT", field_length = 50)
arcpy.AddField_management(newfc, "Time", "TEXT", field_length = 20)

 

# Reference Cursors
cursor=arcpy.da.InsertCursor(newfc, ["X", "Y", "Data", "Time", "SHAPE@XY"])

 

# Read Input File
a = open(dataFile,"r")
inputF = a.readlines()

 

for line in inputF:
   mySplit = line.split("\t")
   xCoordinate = float(mySplit[0])
   yCoordinate = float(mySplit[1])
   timeData = str(mySplit[2])
   zValue = float(mySplit[3])
   newRow = (xCoordinate, yCoordinate, zValue, timeData, (xCoordinate, yCoordinate))
   cursor.insertRow(newRow)
a.close()


# Desired Spatial Reference
out_coordinate_system = arcpy.SpatialReference('Projected Coordinate Systems/World/WGS 1984 World Mercator')

# New Projection for better accuracy of downstream analysis
arcpy.Project_management(newfcName, newfcNameProject, out_coordinate_system)

____________________________________________________________________

Thank you.

Outcomes