'Floating licenses' being taken by script

8202
13
03-10-2014 10:22 AM
ClintDow
Occasional Contributor
Hello all,

I feel like I'm missing something simple, but I have a script that uses arcpy.CreateRandomPoints_management which requires either a spatial analyst license or ArcInfo license.

At work we have a floating ArcInfo license, so if the license is free the script automatically uses it, even though at no point in my script do I import ArcInfo. I do however check out spatial analyst, we have multiple licenses for sa, so I would rather use SA than holding up ArcInfo for the duration of the script (which in this case will be quite a long time)

The script is actually taking both licenses now that I check, so for this one script to run its taking both spatial analyst and ArcInfo. Is there some way to force it to ONLY use spatial analyst? I have tried explicit setting arcpy.SetProduct('ArcView') which does not seem to have any effect.

edit: I should mention this is being run as a standalone script, not from within Arc
Tags (2)
0 Kudos
13 Replies
JoshuaChisholm
Occasional Contributor III
Hello Clint,

I think when you import arcpy it will automatically checkout whichever copy of ArcGIS you are set up for (see Start > All Programs > ArcGIS > ArcGIS Administrator > Desktop). You'll have to use two liences at once (sa and some level of ArcGIS).

If you want to start the script by forcing the software level to ArcView, I would try something like this (changes the local environmental variables):
import os
os.system('SETX ESRI_SOFTWARE_CLASS "Viewer"')

import arcpy
#do stuff

Let me know if that is what you're looking for.
0 Kudos
ClintDow
Occasional Contributor
Hello Clint,

I think when you import arcpy it will automatically checkout whichever copy of ArcGIS you are set up for (see Start > All Programs > ArcGIS > ArcGIS Administrator > Desktop). You'll have to use two liences at once (sa and some level of ArcGIS).

If you want to start the script by forcing the software level to ArcView, I would try something like this (changes the local environmental variables):
import os
os.system('SETX ESRI_SOFTWARE_CLASS "Viewer"')

import arcpy
#do stuff

Let me know if that is what you're looking for.


Hello thank you for the reply,

I have triple-checked that my licensing level in ArcGIS Administrator is at Basic, disabled Spatial Analyst in the Extentions dialogue in both ArcMap and ArcCatalog and checked in the 'Where have all the Licenses gone' application to ensure the licenses were not in use before running the script, but the issue is still persisting.

Also I tried setting ESRI_SOFTWARE_CLASS as shown in your example, I get a confirmation message above my script output but unfortunately the licenses still get used up. Also I tried running that command in a cmd prompt then running my script from the prompt, but still get the same result.
To make it even weirder, I signed out the ArcInfo license on another workstation, ran my script on my workstation, and it automatically took out an ArcEditor license instead. None of the geoprocessing tools require an ArcEditor license level, so I don't know why it would take that license in the first place.

edit: I created a toolbox and edited the script to run from ArcCatalog rather than standalone, and the licenses are behaving as expected, so it seems to only happen when the script is run outside of arc.
0 Kudos
JoshuaChisholm
Occasional Contributor III
That's strange, I wouldn't have guess that. There must be a weird initialization process for starting arcpy where is grabs the highest licence if it can. I'm guessing you have the administrative right to change your licence level using ArcGIS Administrator. Does it grab the highest licence as soon as it executes import arcpy?
0 Kudos
ClintDow
Occasional Contributor
Yes, it appears to immediately after importing arcpy, on the very next row arcpy.ProductInfo() returns 'ArcEditor' (ArcInfo is still in use on another workstation at this point.) I guess its initializing a new instance of arc entirely and grabs the highest available license.

Interestingly it outputs 'ArcEditor' both times when running this:

import arcpy
arcpy.AddMessage(arcpy.ProductInfo())

import os
os.system('SETX ESRI_SOFTWARE_CLASS "Viewer"')

arcpy.AddMessage(arcpy.ProductInfo())
0 Kudos
curtvprice
MVP Esteemed Contributor

Clint, the os.system call will set the environment variable but env variable settings only affect new Desktop apps when they start up.  It will have no effect on the current environment within your script, or any standalone Python scripts.

Note, arcpy.SetProduct() has no effect - it's been left there so old scripts won't be broken but it doesn't do anything.

Luke is right - the way to get this to work correctly is to import arcview ("ArcGIS Basic") before arcpy.

import arcview

import arcpy

sa_status = arcpy.CheckOutExtension("spatial")

arcpy.AddMessage("ArcGIS product: " + arcpy.ProductInfo())

arcpy.AddMessage("Spatial Analyst: " + sa_status) # "CheckedOut"

Help 10.2: Accessing license and extensions in Python

0 Kudos
Luke_Pinner
MVP Regular Contributor
Try importing arcview before arcpy:
import arcview, arcpy
0 Kudos
JoshuaBrengel
New Contributor III

I realize this is quite and old question, but rather than create a new post for the very same question:  @ Clint Dow, did Curtis or Luke's suggestions work for you?  I have the same issue.  When running my python scripts where I import the arcpy module, I'd rather use the arcview license than the arcinfo license in order to keep the advanced license free for our GIS developer.  Thanks!

0 Kudos
MichaelVolz
Esteemed Contributor

Check out this thread to see if it has any connection to this issue:

https://community.esri.com/message/698500-re-import-arceditor-does-not-set-proper-license-level?comm... 

0 Kudos
JoshuaBrengel
New Contributor III

Thanks for the quick reply Michael.  I'm running ArcMap 10.4 Python 2.7 in IDLE.  Based on my interpretation of the post you linked in your response above, it seems like there is conflicting information on if you can import arcview and not pull down the highest license level- in my case an arcinfo license. 

Xander seemed to claim he did not successfully import arcview but Ronald said it was possible to import arcview without pulling the highest level (to which Xander replied seeming to agree that conclusion).  All that aside, I'm guessing I won't have an issue in 10.4 as long as I import arcview before I import arcpy?  Also, it will only pull one basic licenses, not two basic licenses, if I run a script and then open up an instance of ArcMap, correct? 

Thanks again!

0 Kudos