<?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 Understanding &amp;quot;cannot acquire a lock&amp;quot; in systems with limited access in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/understanding-quot-cannot-acquire-a-lock-quot-in/m-p/713603#M55351</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&amp;gt; "arcpy.Project_management(newfcName, newfcNameProject, out_coordinate_system)"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get two "cannot acquire lock" messages in a row, and a failure to execute message that kills the program:&lt;/P&gt;&lt;P&gt;"Error 999999: Error Executing Function.&lt;/P&gt;&lt;P&gt;Cannot acquire a lock.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cannot acquire a lock.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Failed to execute (Project)"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And here's an abbreviated version of the code below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;outpath = r"C:/PATH/TO/OUTFOLDER/"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;dataFile = "C:/PATH/TO/INPUT/input.csv"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;arcpy.env.overwriteOutput=True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.env.workspace= outpath&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;newfcName = "OriginalData.shp" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; newfcNameProject = "ProjectedData.shp" &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;# Shapefile with the coordinate system of the coordinate data within input&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; projectedexample = "ExampleData-in-Input-Coordinate-Format.prj"&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; # creating table to be filled&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; newfc = arcpy.CreateFeatureclass_management(outpath, newfcName, "POINT", "", "", "", projectedexample)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.AddField_management(newfc, "X", "FLOAT", field_length = 50)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.AddField_management(newfc, "Y", "FLOAT", field_length = 50)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.AddField_management(newfc, "Data", "FLOAT", field_length = 50)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.AddField_management(newfc, "Time", "TEXT", field_length = 20)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;# Reference Cursors&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; cursor=arcpy.da.InsertCursor(newfc, ["X", "Y", "Data", "Time", "SHAPE@XY"])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;# Read Input File&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; a = open(dataFile,"r")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; inputF = a.readlines()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;for line in inputF:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;mySplit = line.split("\t")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;xCoordinate = float(mySplit[0])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;yCoordinate = float(mySplit[1])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;timeData = str(mySplit[2])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;zValue = float(mySplit[3])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;newRow = (xCoordinate, yCoordinate, zValue, timeData, (xCoordinate, yCoordinate))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;cursor.insertRow(newRow)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; a.close()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; #&amp;nbsp;Desired Spatial Reference&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; out_coordinate_system = arcpy.SpatialReference('Projected Coordinate Systems/World/WGS 1984 World Mercator')&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;# New Projection for better accuracy of downstream analysis&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.Project_management(newfcName, newfcNameProject, out_coordinate_system)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;____________________________________________________________________&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Oct 2020 19:23:10 GMT</pubDate>
    <dc:creator>EliseosMucaki</dc:creator>
    <dc:date>2020-10-09T19:23:10Z</dc:date>
    <item>
      <title>Understanding "cannot acquire a lock" in systems with limited access</title>
      <link>https://community.esri.com/t5/python-questions/understanding-quot-cannot-acquire-a-lock-quot-in/m-p/713603#M55351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&amp;gt; "arcpy.Project_management(newfcName, newfcNameProject, out_coordinate_system)"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get two "cannot acquire lock" messages in a row, and a failure to execute message that kills the program:&lt;/P&gt;&lt;P&gt;"Error 999999: Error Executing Function.&lt;/P&gt;&lt;P&gt;Cannot acquire a lock.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cannot acquire a lock.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Failed to execute (Project)"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And here's an abbreviated version of the code below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;outpath = r"C:/PATH/TO/OUTFOLDER/"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;dataFile = "C:/PATH/TO/INPUT/input.csv"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;arcpy.env.overwriteOutput=True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.env.workspace= outpath&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;newfcName = "OriginalData.shp" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; newfcNameProject = "ProjectedData.shp" &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;# Shapefile with the coordinate system of the coordinate data within input&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; projectedexample = "ExampleData-in-Input-Coordinate-Format.prj"&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; # creating table to be filled&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; newfc = arcpy.CreateFeatureclass_management(outpath, newfcName, "POINT", "", "", "", projectedexample)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.AddField_management(newfc, "X", "FLOAT", field_length = 50)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.AddField_management(newfc, "Y", "FLOAT", field_length = 50)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.AddField_management(newfc, "Data", "FLOAT", field_length = 50)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.AddField_management(newfc, "Time", "TEXT", field_length = 20)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;# Reference Cursors&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; cursor=arcpy.da.InsertCursor(newfc, ["X", "Y", "Data", "Time", "SHAPE@XY"])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;# Read Input File&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; a = open(dataFile,"r")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; inputF = a.readlines()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;for line in inputF:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;mySplit = line.split("\t")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;xCoordinate = float(mySplit[0])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;yCoordinate = float(mySplit[1])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;timeData = str(mySplit[2])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;zValue = float(mySplit[3])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;newRow = (xCoordinate, yCoordinate, zValue, timeData, (xCoordinate, yCoordinate))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;cursor.insertRow(newRow)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; a.close()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; #&amp;nbsp;Desired Spatial Reference&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; out_coordinate_system = arcpy.SpatialReference('Projected Coordinate Systems/World/WGS 1984 World Mercator')&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;# New Projection for better accuracy of downstream analysis&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt; arcpy.Project_management(newfcName, newfcNameProject, out_coordinate_system)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;____________________________________________________________________&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2020 19:23:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/understanding-quot-cannot-acquire-a-lock-quot-in/m-p/713603#M55351</guid>
      <dc:creator>EliseosMucaki</dc:creator>
      <dc:date>2020-10-09T19:23:10Z</dc:date>
    </item>
  </channel>
</rss>

