1

I want to find the shortest path between two points. I first make a route layer from an analysis network and then add two point locations. While python shows the following errors when I use the solve function. Can anyone tell me the reason? ExecuteError: Failed to execute. Parameters are not valid. ERROR 000824: The tool is not licensed. Failed to execute (Solve).

Code works when I use Python window in ArcMap and I actually have all ArcGIS licenses

codes: '''

import arcpy
import os

arcpy.env.workspace = r"C:\Users\hyan1\Desktop\try\network\network_for_wageningen.mdb"
network = r'C:\Users\hyan1\Desktop\try\network\network_for_wageningen.mdb\network2_ND'
outNALayer = arcpy.na.MakeRouteLayer(network, "WorkRoute", "length")
outNALayer = outNALayer.getOutput(0)
subLayerNames = arcpy.na.GetNAClassNames(outNALayer)
points_layername = subLayerNames["Stops"]
routes_layername = subLayerNames["Routes"]

### add location, solve and export
input_point = r'C:\\Users\hyan1\Desktop\Route_2\T11_1_11_pro_lyr_1.shp'
output_name = os.path.split(input_point)[1]
arcpy.na.AddLocations(outNALayer, points_layername, input_point, "", "", "DateTimeS")
arcpy.na.Solve(outNALayer)
arcpy.FeatureClassToFeatureClass_conversion("WorkRoute\Routes", r"C:\Users\hyan1\Desktop\Route_2\shortest_route", output_name)

'''

1 Answer 1

2

This error is actually documented on the Error: 000824 page.

The solution is to

Add the following code snippet to check-out the extension containing the tool before calling the tool for use:

   import arcpy
   …
   arcpy.CheckOutExtension("[Extension name]")

The extension names are documented in the arcpy.CheckOutExtension help. For Network Analyst use:

arcpy.CheckOutExtension("Network")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.