<?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 Errors in standalone script when copying Route Event Layer to fgb  in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/errors-in-standalone-script-when-copying-route/m-p/832218#M3212</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on a standalone python script that dissolves speed data across a network to perform a daily refresh a table in our enterprise geodatabase.&amp;nbsp; I've made the script work&amp;nbsp;several ways when running in the ArcCatalog python window.&amp;nbsp; I am running into errors when trying to run as a standalone script.&amp;nbsp; Pretty much generic error&amp;nbsp;codes as noted in the abbreviated script below.&amp;nbsp; I've tried specifying the event route layer be written to the current workspace and&amp;nbsp; scratch workspace.&amp;nbsp; &amp;nbsp;Any suggestions?&amp;nbsp;&amp;nbsp;&amp;nbsp;Working in 10.7.1.&amp;nbsp; 32 bit execution in catalog and stand alone. Relatively new to python.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;db_connect = r"Database Connections//GIS on GISD.sde"&lt;BR /&gt;arcpy.env.workspace = r'\\GIS_SEVER\Workspace\Speeds_Dissolve\Speeds_Working.gdb' &lt;BR /&gt;arcpy.env.scratchWorkspace = r'\\GIS_SERVER\Workspace\Speeds_Dissolve\Scratch.gdb'&lt;BR /&gt;outFGB = r'\\GIS_SERVER\Workspace\Speeds_Dissolve\Speeds_Working.gdb' &lt;BR /&gt;scratchFGB = r'\\GIS_SERVER\Workspace\Speeds_Dissolve\Scratch.gdb'&lt;BR /&gt;ToTable = db_connect + "\GDP_OWN.O_SPEED_SEGMENT_DIS"&lt;/P&gt;&lt;P&gt;#define tables &lt;BR /&gt;#multiple tables&lt;BR /&gt;speed_dis = outFGB + "\speed_dis"&lt;BR /&gt;speed_lrs_dis_lines = outFGB + "\speed_lrs_dis_lines"&lt;BR /&gt;speed_mrel = scratchFGB + "\speed_mrel"&lt;/P&gt;&lt;P&gt;#step - clean up data from previous run if exists - successfully completes&lt;BR /&gt;#step - use query layer to export LRS layer to fgb (&lt;SPAN&gt;mp_detail_lrs)&lt;/SPAN&gt;&amp;nbsp; - successfully completes&lt;BR /&gt;#step - user query layer to export speed data to table - successfully completes&lt;BR /&gt;#step - define fields name for speeds, MakeTableView, and save to fgb - successfully completes&lt;BR /&gt;#step - DissolveRouteEvents_lr using table from previous step, speed_dis - successfully completes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#step - MakeRouteEventLayer - successfully completes&lt;BR /&gt;props = "ROUTE_I LINE BEGIN_GIS_MP_NUM_I END_GIS_MP_NUM_I"&lt;BR /&gt;arcpy.MakeRouteEventLayer_lr(mp_detail_lrs,"ROUTE_I", speed_dis, props,speed_mrel,"#","ERROR_FIELD")&lt;BR /&gt;result4 = arcpy.GetCount_management(speed_mrel)&lt;BR /&gt;print ("Speed QL (speed_mrel) record count:" + str(result4)) #returns count successfully&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#step - export/copy Route event layer to fgb - NOT SUCCESSFUL as standalone&lt;/P&gt;&lt;P&gt;#option1 - arcpy.CopyFeatures_management(speed_mrel,speed_lrs_dis_lines)&lt;BR /&gt;##--line 2568, in CopyFeatures raise ERROR 999998: Unexpected Error.Failed to execute (CopyFeatures)&lt;/P&gt;&lt;P&gt;#arcpy.CopyRows_management(speed_mrel,speed_lrs_dis_lines)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;##option 2 - ArcGIS\Desktop10.7\ArcPy\arcpy\management.py", line 18093, in CopyRows -- ERROR 999998: Unexpected Error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#option 3 - arcpy.Append_management(speed_mrel, speed_lrs_dis_lines,"NO_TEST")&lt;BR /&gt;##Traceback (most recent call last):&lt;BR /&gt;##File "Q:\Speeds_Dissolve\dissolve_speeds3.py", line 186, in &amp;lt;module&amp;gt;&lt;BR /&gt;##arcpy.Append_management(speed_mrel, speed_lrs_dis_lines,"NO_TEST")&lt;BR /&gt;##File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\management.py", line 4256, in Append&lt;BR /&gt;##raise e ExecuteError: ERROR 999998: Unexpected Error. Failed to execute (Append).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#option 4 - Attempting cursor, no error message, no records inserted into fgb table&lt;BR /&gt;dsc = arcpy.Describe(speed_mrel) #route event layer&lt;BR /&gt;fields = dsc.fields&lt;BR /&gt;fieldnames = [field.name for field in fields if field.name != dsc.OIDFieldName and field.name != 'SHAPE.LEN' and field.name != 'Shape'] &lt;BR /&gt;fieldnames.append('SHAPE@')&lt;BR /&gt;print (fieldnames) #expected fields are returned&lt;BR /&gt;query = "select * from speed_mrel"&lt;BR /&gt;with arcpy.da.SearchCursor(speed_mrel, fieldnames,query)as sCur1:&lt;BR /&gt; with arcpy.da.InsertCursor(speed_lrs_dis_lines,fieldnames) as iCur1:&lt;BR /&gt; for row in sCur1:&lt;BR /&gt; printf = row.getValue(Field1)&lt;BR /&gt; print (printf)&lt;BR /&gt; iCur1.insertRow(row)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Jul 2020 21:02:03 GMT</pubDate>
    <dc:creator>JeffTrudnak</dc:creator>
    <dc:date>2020-07-23T21:02:03Z</dc:date>
    <item>
      <title>Errors in standalone script when copying Route Event Layer to fgb</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/errors-in-standalone-script-when-copying-route/m-p/832218#M3212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on a standalone python script that dissolves speed data across a network to perform a daily refresh a table in our enterprise geodatabase.&amp;nbsp; I've made the script work&amp;nbsp;several ways when running in the ArcCatalog python window.&amp;nbsp; I am running into errors when trying to run as a standalone script.&amp;nbsp; Pretty much generic error&amp;nbsp;codes as noted in the abbreviated script below.&amp;nbsp; I've tried specifying the event route layer be written to the current workspace and&amp;nbsp; scratch workspace.&amp;nbsp; &amp;nbsp;Any suggestions?&amp;nbsp;&amp;nbsp;&amp;nbsp;Working in 10.7.1.&amp;nbsp; 32 bit execution in catalog and stand alone. Relatively new to python.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;db_connect = r"Database Connections//GIS on GISD.sde"&lt;BR /&gt;arcpy.env.workspace = r'\\GIS_SEVER\Workspace\Speeds_Dissolve\Speeds_Working.gdb' &lt;BR /&gt;arcpy.env.scratchWorkspace = r'\\GIS_SERVER\Workspace\Speeds_Dissolve\Scratch.gdb'&lt;BR /&gt;outFGB = r'\\GIS_SERVER\Workspace\Speeds_Dissolve\Speeds_Working.gdb' &lt;BR /&gt;scratchFGB = r'\\GIS_SERVER\Workspace\Speeds_Dissolve\Scratch.gdb'&lt;BR /&gt;ToTable = db_connect + "\GDP_OWN.O_SPEED_SEGMENT_DIS"&lt;/P&gt;&lt;P&gt;#define tables &lt;BR /&gt;#multiple tables&lt;BR /&gt;speed_dis = outFGB + "\speed_dis"&lt;BR /&gt;speed_lrs_dis_lines = outFGB + "\speed_lrs_dis_lines"&lt;BR /&gt;speed_mrel = scratchFGB + "\speed_mrel"&lt;/P&gt;&lt;P&gt;#step - clean up data from previous run if exists - successfully completes&lt;BR /&gt;#step - use query layer to export LRS layer to fgb (&lt;SPAN&gt;mp_detail_lrs)&lt;/SPAN&gt;&amp;nbsp; - successfully completes&lt;BR /&gt;#step - user query layer to export speed data to table - successfully completes&lt;BR /&gt;#step - define fields name for speeds, MakeTableView, and save to fgb - successfully completes&lt;BR /&gt;#step - DissolveRouteEvents_lr using table from previous step, speed_dis - successfully completes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#step - MakeRouteEventLayer - successfully completes&lt;BR /&gt;props = "ROUTE_I LINE BEGIN_GIS_MP_NUM_I END_GIS_MP_NUM_I"&lt;BR /&gt;arcpy.MakeRouteEventLayer_lr(mp_detail_lrs,"ROUTE_I", speed_dis, props,speed_mrel,"#","ERROR_FIELD")&lt;BR /&gt;result4 = arcpy.GetCount_management(speed_mrel)&lt;BR /&gt;print ("Speed QL (speed_mrel) record count:" + str(result4)) #returns count successfully&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#step - export/copy Route event layer to fgb - NOT SUCCESSFUL as standalone&lt;/P&gt;&lt;P&gt;#option1 - arcpy.CopyFeatures_management(speed_mrel,speed_lrs_dis_lines)&lt;BR /&gt;##--line 2568, in CopyFeatures raise ERROR 999998: Unexpected Error.Failed to execute (CopyFeatures)&lt;/P&gt;&lt;P&gt;#arcpy.CopyRows_management(speed_mrel,speed_lrs_dis_lines)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;##option 2 - ArcGIS\Desktop10.7\ArcPy\arcpy\management.py", line 18093, in CopyRows -- ERROR 999998: Unexpected Error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#option 3 - arcpy.Append_management(speed_mrel, speed_lrs_dis_lines,"NO_TEST")&lt;BR /&gt;##Traceback (most recent call last):&lt;BR /&gt;##File "Q:\Speeds_Dissolve\dissolve_speeds3.py", line 186, in &amp;lt;module&amp;gt;&lt;BR /&gt;##arcpy.Append_management(speed_mrel, speed_lrs_dis_lines,"NO_TEST")&lt;BR /&gt;##File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\management.py", line 4256, in Append&lt;BR /&gt;##raise e ExecuteError: ERROR 999998: Unexpected Error. Failed to execute (Append).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#option 4 - Attempting cursor, no error message, no records inserted into fgb table&lt;BR /&gt;dsc = arcpy.Describe(speed_mrel) #route event layer&lt;BR /&gt;fields = dsc.fields&lt;BR /&gt;fieldnames = [field.name for field in fields if field.name != dsc.OIDFieldName and field.name != 'SHAPE.LEN' and field.name != 'Shape'] &lt;BR /&gt;fieldnames.append('SHAPE@')&lt;BR /&gt;print (fieldnames) #expected fields are returned&lt;BR /&gt;query = "select * from speed_mrel"&lt;BR /&gt;with arcpy.da.SearchCursor(speed_mrel, fieldnames,query)as sCur1:&lt;BR /&gt; with arcpy.da.InsertCursor(speed_lrs_dis_lines,fieldnames) as iCur1:&lt;BR /&gt; for row in sCur1:&lt;BR /&gt; printf = row.getValue(Field1)&lt;BR /&gt; print (printf)&lt;BR /&gt; iCur1.insertRow(row)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2020 21:02:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/errors-in-standalone-script-when-copying-route/m-p/832218#M3212</guid>
      <dc:creator>JeffTrudnak</dc:creator>
      <dc:date>2020-07-23T21:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Errors in standalone script when copying Route Event Layer to fgb</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/errors-in-standalone-script-when-copying-route/m-p/832219#M3213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jeff,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A few suggestions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to change your path to the full path. Instead of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;db_connect = r"Database Connections//GIS on GISD.sde"&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;which will work from within Catalog, try something like:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;db_connect = r" C:\Users\USERNAME\AppData\Roaming\Esri\ArcGISPro.......sde" (you can get the full path from the sde properties window)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that in line 4&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;GIS_SEVER&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;I assume it should be&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;GIS_SERVER&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;Add two backslashes or r in path. I&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;nstead of:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;speed_mrel = scratchFGB + "\speed_mrel"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;Write:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;speed_mrel = scratchFGB + "\\speed_mrel" &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;or&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;speed_mrel = scratchFGB + r"\speed_mrel"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Hope this helps,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Uri&lt;/SPAN&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;EM&gt;If this answer solved your question or if you found it helpful please mark it accordingly to help others who have the same question.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2020 05:40:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/errors-in-standalone-script-when-copying-route/m-p/832219#M3213</guid>
      <dc:creator>UriGilad_EsriAu</dc:creator>
      <dc:date>2020-07-24T05:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: Errors in standalone script when copying Route Event Layer to fgb</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/errors-in-standalone-script-when-copying-route/m-p/832220#M3214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the suggestions.&amp;nbsp; I tried multiple ways of specifying the path, but still no luck with exporting the Route Event Layer to the fgb.&amp;nbsp; &amp;nbsp;The script successfully reads from the enterprise db, creates and copies query layers to the fgb, creates and copies a table view from/to the fgb.&amp;nbsp; I just don't know what is different between the route event layer and the other in memory tables that are working without issue.&amp;nbsp; I've tried handling the route event layer the same way as the query layers/table view where&amp;nbsp;I don't specify a full path.&amp;nbsp; I find it interesting that the copy features command is creating the table in the fgb before failing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;speeds_lrs_errors = outFGB + "\speeds_lrs_errors" &lt;BR /&gt;speed_mrel = scratchFGB + r"\speed_mrel"&lt;BR /&gt;arcpy.MakeRouteEventLayer_lr(mp_detail_lrs,"ROUTE_I", speed_dis, props,"speed_mrel","#","ERROR_FIELD")&lt;BR /&gt;arcpy.CopyFeatures_management(speed_mrel,speed_lrs_dis_lines)&lt;/P&gt;&lt;P&gt;works in catalog, as standalone creates speed_lrs_dis_lines in FGB then fails&lt;BR /&gt;--&lt;BR /&gt;speeds_lrs_errors = outFGB + "\speeds_lrs_errors" &lt;BR /&gt;speed_mrel = scratchFGB + r"\speed_mrel"&lt;BR /&gt;arcpy.MakeRouteEventLayer_lr(mp_detail_lrs,"ROUTE_I", speed_dis, props,"speed_mrel","#","ERROR_FIELD")&lt;BR /&gt;arcpy.Append_management(speed_mrel,speed_lrs_dis_lines,"NO_TEST")&lt;/P&gt;&lt;P&gt;works in catalog, fails as stand alone&lt;BR /&gt;--&lt;BR /&gt;speed_lrs_dis_lines = outFGB + "\\speed_lrs_dis_lines"&lt;BR /&gt;speed_mrel = scratchFGB + "\\speed_mrel"&lt;BR /&gt;arcpy.MakeRouteEventLayer_lr(mp_detail_lrs,"ROUTE_I", speed_dis, props,"speed_mrel","#","ERROR_FIELD")&lt;BR /&gt;arcpy.CopyFeatures_management(speed_mrel,speed_lrs_dis_lines)&lt;/P&gt;&lt;P&gt;works in catalog, as standalone creates speed_lrs_dis_lines in FGB then fails&lt;BR /&gt;--&lt;BR /&gt;speed_lrs_dis_lines = outFGB + "\\speed_lrs_dis_lines"&lt;BR /&gt;speed_mrel = scratchFGB + "\\speed_mrel"&lt;BR /&gt;arcpy.MakeRouteEventLayer_lr(mp_detail_lrs,"ROUTE_I", speed_dis, props,"speed_mrel","#","ERROR_FIELD")&lt;BR /&gt;arcpy.Append_management(speed_mrel,speed_lrs_dis_lines,"NO_TEST")&lt;/P&gt;&lt;P&gt;works in catalog, fails as stand alone&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2020 21:01:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/errors-in-standalone-script-when-copying-route/m-p/832220#M3214</guid>
      <dc:creator>JeffTrudnak</dc:creator>
      <dc:date>2020-07-24T21:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Errors in standalone script when copying Route Event Layer to fgb</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/errors-in-standalone-script-when-copying-route/m-p/832221#M3215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So there was nothing wrong with the script itself.&amp;nbsp; The python script resides on one of our servers used for scheduled jobs.&amp;nbsp; I had access to a shared directory on the server, but could not login to the server.&amp;nbsp; I had been trying to execute the script from my workstation by accessing the shared directory.&amp;nbsp; When I asked our server admin to run the script while logged into the server, the script ran without issue. &amp;nbsp; Again, not sure why this is an issue for the event layer when working with the query layers in the script before the event layer were successful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Sep 2020 14:15:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/errors-in-standalone-script-when-copying-route/m-p/832221#M3215</guid>
      <dc:creator>JeffTrudnak</dc:creator>
      <dc:date>2020-09-01T14:15:12Z</dc:date>
    </item>
  </channel>
</rss>

