spatial license "NotLicensed" in stand alone script...

2083
16
04-09-2014 05:45 AM
MichaelBlom
New Contributor III
... but fine (Available) when I debug the script in a python IDE.

In this doc on page 116, I read that the setting of product and extensions is necessary only within stand alone scripts.

So in my py script, I first do the full check for the spatial analyst license, but it fails when I call this script from a command window.

If I open administrator, and see what I have installed, Spatial Analyst is there: Installed, Authorized and Permanent (non expiring). Single Use, so no license server to point at.

Does anyone have any hints about how I can solve this?

Thanks,
Mike
Tags (2)
0 Kudos
16 Replies
JamesCrandall
MVP Frequent Contributor
Not exactly sure what your specific problem is that you are experiencing, but here is how you would check out a license, perform the analysis and then check the license back in.


      ### see if spatial analyst extension is available for use
      availability = arcpy.CheckExtension("Spatial")
      if availability == "Available":
         arcpy.CheckOutExtension("Spatial")
         print "SA Ext has been checked out"
      else:
         print "%s extension is not available (%s)"%("Spatial Analyst Extension",availability)
         print "Please ask someone who has it checked out but not using to turn off the extension"
         return
                
      #run the analysis     
      arcpy.sa.Sample(rasters2, transect_in, outtab)

      #return the extension
      arcpy.CheckInExtension("Spatial")

0 Kudos
MichaelBlom
New Contributor III
thanks for replying James:

I have these lines:

if arcpy.CheckExtension("Spatial")=="Available":
    do something
else:
    arcpy.AddMessage("Spatial Analyst Licenses status: "+ arcpy.CheckExtension("Spatial"))
    arcpy.AddMessage(arcpy.ProductInfo())

I log the messages out:

Spatial Analyst Licenses status: NotLicensed
ArcServer

When I open ArcMap, it tells me I have spatial analyst.
0 Kudos
MichaelBlom
New Contributor III
Screen shot of what my administrator looks like:
0 Kudos
MichaelBlom
New Contributor III
screen shot of what my administrator looks like
0 Kudos
MathewCoyle
Frequent Contributor
As James said earlier you have to actually check out the license with this line.
arcpy.CheckOutExtension("Spatial")
0 Kudos
MichaelBlom
New Contributor III
Hi Matthew,

A "check-out" would occur after checking and seeing that the license is available - I am being told that no license is available, so I cannot proceed to check it out.

Besides, a check out would not apply for a stand-alone license, would it? only if there's a license server (which i don't have)

I think the real clue is when I print out this statment: arcpy.AddMessage(arcpy.ProductInfo())
and I get as a result:
ArcServer

This box has arcgis server and arcmap installed.  Perhaps there is a conflict with the "License Levels". Perhaps at the arcserver license level there is no access to desktop extensions via scripting?

Someone from ESRI?
0 Kudos
MathewCoyle
Frequent Contributor
Ahh yes. An ArcServer install cannot use desktop licenses.

Are you using 64 bit Python for desktop?

What is your output from sys.path?
0 Kudos
MichaelBlom
New Contributor III
sys.path[0] is just the path that the script is running from

I didn't print out other sys.path values, is there a specific value in the list?

the only version of python i have is here: D:\Python27\ArcGISx6410.2\python.exe
0 Kudos
MathewCoyle
Frequent Contributor
The entire sys.path output will tell you if you are reading from the desktop or server libraries or both.
0 Kudos