Python Script for Spatial Analyst, License Error

I have been trying to get a little Python script from this tutorial to run for and hour, and kept getting errors:

import arcgisscripting
gp = arcgisscripting.create()
gp.workspace = “c:/users/arne/downloads/Python_ArcGIS_Lessons/Lesson2/Lesson2”
gp.overwriteoutput = 1

gp.select_analysis(“flowline.shp”, “RBCreek.shp”, ‘ “GNIS_Name” = \’Red Butte Creek\’ ‘)
gp.buffer_analysis(“RBCreek.shp”, “RBCreekBuff.shp”, “100”)
gp.PolygonToRaster_conversion(“RBCreekBuff.shp”, “FID”, “BuffGrd”, “CELL_CENTER”, “NONE”,  “30”)
del gp


Traceback (most recent call last):
  File “C:\Users\….\”, line 15, in <module>
    gp.PolygonToRaster_conversion(“RBCreekBuff.shp”, “FID”, “BuffGrd”, “CELL_CENTER”, “NONE”,  “30”)
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000824: The tool is not licensed.
Failed to execute (PolygonToRaster).

Based on google searches for “ERROR 000824: The tool is not licensed.” I tried turning on the Spatial Analyst under ‘Extensions’ in ArcCatalog and ArcMap. I could never get it to work.

Finally, I found this page here. Apparently you have to “turn on” Spatial Analyst from within the Python script by adding the line:


That finally worked !



Filed under Uncategorized

3 responses to “Python Script for Spatial Analyst, License Error

  1. Niels

    Thanks!! Just what I was looking for!

  2. Carrie

    Brilliant! Thanks!

  3. luis silva

    Good evening, I am trying to solve this problem, but can not because the page that indicated is no longer available.

    can you explain how to “turn on” Spatial Analyst within the Python script adding the line:

    gp.CheckOutExtension (“Spatial”) gp.CheckOutExtension (“Space”), “because I do not know how.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s