ArcGIS RuntimeError – Fix Error 999999 When Using gp.setProduct()

arcgis-10.2arcgis-desktoparcgis-license-managerarcpy

I am developing a script that will be used in ArcGIS Desktop 10.2 of Standard (formerly called ArcEditor) license level and thus importing arceditor to make sure I don't use GP tools that require Advanced (formerly called ArcInfo) license level (which I have) while developing the script.

I get the ERROR 999999: Error executing function when running the script in PyScripter. As outlined in the help, one has to import arceditor before importing arcpy. When running this single line of code:

import arceditor

When executing this single line of code, I get the C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arceditor.py file open in PyScripter and it seems that it has troubles setting product (this line is highlighted):

gp.setProduct("ArcEditor")

I have tried re-opening PyScripter, same error. import arcview gives the same error.
Did I get it right that one can set using Standard (formerly called ArcEditor) license while having an ArcGIS Desktop licensed with Advanced (formerly called ArcInfo) installed on the machine? If not in this way, how then?

Best Answer

Given your updated comment, I will summarize in an answer.

From the online help section "Accessing licenses and extensions in Python":

When using an ArcGIS for Desktop Basic or Standard license, a script should set the product to Basic or Standard. Likewise, when using an Engine or EngineGeoDB license, a script should set the product to Engine or EngineGeoDB. If a license is not explicitly set, the license will be initialized based on the highest available license level the first time an ArcPy tool, function, or class is accessed... If the necessary licenses are not available, a tool fails and returns error messages. For example, if you install with an ArcGIS for Desktop Basic license, and you attempt to execute a tool that requires a Standard or Advanced license, the tool will fail.

Therefore, with arcpy you are not able to "upgrade" or "downgrade" to a different license which is unavailable to the user without getting a failure. Therefore, if you are running ANY single-use licenses on your computer, then that is the ONLY license level you will have available.

For example, if I am a developer running an ArcInfo license, wishing to distribute a tool I developed, I can only test that as an ArcInfo license. I cannot test the tool as if I were running an ArcView license. This of course can be good and bad.

  1. If you forget to (or choose not to) set an explicit license level, and you have a license manager with available ArcView, ArcEditor, & ArcInfo licenses, it will always grab the ArcInfo. In this case, you know all the tools will be available. That's good.

  2. If however, your tool requires edit permissions to an Enterprise Geodatabase, and both your AE & AI licenses are already being consumed by other users, it will grab the AV license, and of course, fail. The same cane be said for GP tools that require higher level licenses. That of course, is bad.

Ultimately, you really only need/want to set your product level if you are using a license manager, and you really want to force the script to use one of the 2 lower license levels.

Related Question