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)

'''

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Jan 28, 2021 at 21:23

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")
user2856
73.7k7 gold badges123 silver badges207 bronze badges
answered Jan 28, 2021 at 21:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.