AnsweredAssumed Answered

Server Geolocator Publishing Fails in Python 3.6 but works in 2.7

Question asked by lcecil5 on Dec 12, 2019
Latest reply on Dec 19, 2019 by lcecil5

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 to execute (Publish Service Definition).


Failed to execute (UploadServiceDefinition).


Here is the relevant snippet of the script:


##Publish locators to ArcGIS Server
locator_path = geocoding_dir + "COP_Master_Address_Locator.loc"
sddraft_file = geocoding_dir + "COP_MAF_locator.sddraft"
sd_file = geocoding_dir + ""
service_name = "COP_Master_Address_Locator_test"
summary = "Locator based on City Master Address Points"
tags = "Geolocator"
gis_server_connection_file = r"path\to\myconnection.ags"

# Create the sd draft file
analyze_messages = arcpy.CreateGeocodeSDDraft(locator_path, sddraft_file, service_name,
                           summary=summary, tags=tags, max_result_size=5,
                           max_batch_size=100000, suggested_batch_size=10000,
                           ) ##overwrite_existing_service=True

# Stage and upload the service if the sddraft analysis did not contain errors
if analyze_messages['errors'] == {}:
        # Execute StageService to convert sddraft file to a service definition
        # (sd) file
        arcpy.server.StageService(sddraft_file, sd_file)

        # Execute UploadServiceDefinition to publish the service definition
        # file as a service
        arcpy.server.UploadServiceDefinition(sd_file, gis_server_connection_file)
        print("The geocode service was successfully published")
    except arcpy.ExecuteError:
        print("An error occurred")
    # If the sddraft analysis contained errors, display them
    print("Error were returned when creating service definition draft")
    pprint.pprint(analyze_messages['errors'], indent=2)