import os os.system('SETX ESRI_SOFTWARE_CLASS "Viewer"') import arcpy #do stuff
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.
import arcpy arcpy.AddMessage(arcpy.ProductInfo()) import os os.system('SETX ESRI_SOFTWARE_CLASS "Viewer"') arcpy.AddMessage(arcpy.ProductInfo())
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"
import arcview, arcpy
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!
Check out this thread to see if it has any connection to this issue:
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!