I have a script that creates two geolocators and publishes one of them to our standalone ArcGIS Server (10.7.1). When I run it in Python IDLE 3.6.8 it fails. When I run the exact same script in Python 2.7, it succeeds. I'm trying to get away from using 2.7, but I have a very similar issue with another important script that won't run in Pro or 3.6.8 due to a bug. Is anyone having trouble with Server publishing in Python 3.6.8?
Here is the error that I get in the script and in the server logs. There is nothing specific in the server logs, just this:
An error occurred
ERROR 001487: Failed to update the published service with the server-side data location. Please see the server's log for more details.
ERROR 001369: Failed to create the service.
Failed to execute (Publish Service Definition).
Failed.
Failed to execute (Publish Service Definition).
Failed.
Failed to execute (UploadServiceDefinition).
Here is the relevant snippet of the script:
<SPAN class="comment token">##Publish locators to ArcGIS Server</SPAN>
locator_path <SPAN class="operator token">=</SPAN> geocoding_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"COP_Master_Address_Locator.loc"</SPAN>
sddraft_file <SPAN class="operator token">=</SPAN> geocoding_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"COP_MAF_locator.sddraft"</SPAN>
sd_file <SPAN class="operator token">=</SPAN> geocoding_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"COP_MAF_locator.sd"</SPAN>
service_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"COP_Master_Address_Locator_test"</SPAN>
summary <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Locator based on City Master Address Points"</SPAN>
tags <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Geolocator"</SPAN>
gis_server_connection_file <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"path\to\myconnection.ags"</SPAN>
<SPAN class="comment token"># Create the sd draft file</SPAN>
analyze_messages <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>CreateGeocodeSDDraft<SPAN class="punctuation token">(</SPAN>locator_path<SPAN class="punctuation token">,</SPAN> sddraft_file<SPAN class="punctuation token">,</SPAN> service_name<SPAN class="punctuation token">,</SPAN>
connection_file_path<SPAN class="operator token">=</SPAN>gis_server_connection_file<SPAN class="punctuation token">,</SPAN>
summary<SPAN class="operator token">=</SPAN>summary<SPAN class="punctuation token">,</SPAN> tags<SPAN class="operator token">=</SPAN>tags<SPAN class="punctuation token">,</SPAN> max_result_size<SPAN class="operator token">=</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">,</SPAN>
max_batch_size<SPAN class="operator token">=</SPAN><SPAN class="number token">100000</SPAN><SPAN class="punctuation token">,</SPAN> suggested_batch_size<SPAN class="operator token">=</SPAN><SPAN class="number token">10000</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">##overwrite_existing_service=True</SPAN>
<SPAN class="comment token"># Stage and upload the service if the sddraft analysis did not contain errors</SPAN>
<SPAN class="keyword token">if</SPAN> analyze_messages<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'errors'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># Execute StageService to convert sddraft file to a service definition </SPAN>
<SPAN class="comment token"># (sd) file </SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>server<SPAN class="punctuation token">.</SPAN>StageService<SPAN class="punctuation token">(</SPAN>sddraft_file<SPAN class="punctuation token">,</SPAN> sd_file<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Execute UploadServiceDefinition to publish the service definition </SPAN>
<SPAN class="comment token"># file as a service</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>server<SPAN class="punctuation token">.</SPAN>UploadServiceDefinition<SPAN class="punctuation token">(</SPAN>sd_file<SPAN class="punctuation token">,</SPAN> gis_server_connection_file<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"The geocode service was successfully published"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">except</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ExecuteError<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"An error occurred"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>GetMessages<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># If the sddraft analysis contained errors, display them</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Error were returned when creating service definition draft"</SPAN><SPAN class="punctuation token">)</SPAN>
pprint<SPAN class="punctuation token">.</SPAN>pprint<SPAN class="punctuation token">(</SPAN>analyze_messages<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'errors'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> indent<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>