Stand alone ArcInfo Use?

2748
4
Jump to solution
04-07-2014 07:49 AM
by Anonymous User
Not applicable
At my organization, we have tons of ArcEditor licenses available and everyone is at that license level. We just purchased one ArcInfo license with the hopes that this can by checked out at certain times to use in tools in scripts that when we require ArcInfo tools. I have been reading over some of the documentation, and I cannot quite figure out how to use ArcInfo in a script. Here is my initial test:

>>> import arcinfo  Traceback (most recent call last):   File "<pyshell#0>", line 1, in <module>     import arcinfo   File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcinfo.py", line 18, in <module>     gp.setProduct("ArcInfo") RuntimeError: ERROR 999999: Error executing function. >>> import arceditor >>> import arcinfo >>> import arcpy >>> arcpy.ProductInfo() u'ArcEditor' >>> arcpy.SetProduct('ArcInfo') u'AlreadyInitialized'   # here it says ArcInfo has already been initialized, yet I still am not able to use the near tool >>> pnts = r'C:\TEMP\PermitTest\Wtr_Val.shp' >>> hyd = r'C:\TEMP\PermitTest\Wtr_Hyd.shp' >>> arcpy.Near_analysis(pnts, pnts)  Traceback (most recent call last):   File "<pyshell#7>", line 1, in <module>     arcpy.Near_analysis(pnts, hyd)   File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\analysis.py", line 794, in Near     raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000824: The tool is not licensed. Failed to execute (Near).  >>> arcpy.CheckProduct('ArcInfo') u'Unavailable'


I have been reading this [url=http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000z000000]page[/url] and it says that if the return value for the SetProduct is "AlreadyInitialized", then the license has already been set in the script. This does not appear to be the case, or the more likely scenario is that I am not doing this correctly.

According to the help docs:

Legacy:

The product level should be set by importing the appropriate product module (arcinfo, arceditor, arcview, arcserver, arcenginegeodb, arcengine) prior to importing arcpy. The SetProduct function is a legacy function and cannot set the product once arcpy has been imported.


I cannot import arcpy until I import the right module...I cannot directly import arcinfo as shown above (I'm assuming because I haven't initialized an instance of ArcInfo???). It does let me import arcinfo after I import arceditor though.

Has anyone had experience with temporarily setting the product to ArcInfo while a script is executing? Also, after the change to ArcInfo is successful, do I need to reset the product back to ArcEditor? How do I do this?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
WilliamCraft
MVP Regular Contributor
Caleb, I noticed in your initial post that the arcpy.CheckProduct('ArcInfo') line toward the bottom yields a return of u'Unavailable'.  Could it be that that the ArcInfo license is already in use by someone else at the moment?  I believe that if a license is not or cannot be explicitly set (possibly due to it not being currently available), then the license initialized will be issued using the highest available license level at that time.  In your case, perhaps the ArcEditor is simply the "next best" available license which isn't suitable for the tool you're trying to run.  Do you think this could be the issue?

View solution in original post

0 Kudos
4 Replies
T__WayneWhitley
Frequent Contributor
I think it has to be a stand-alone script.  You're on track, but if you already have a license checked out, you'll get the AlreadyInitialized msg.  So it runs in a 'process'....so, what I had to do was end the currently running script (that checks out ArcInfo by default) and specifically import ArcView (I have no ArcEditor licenses) before importing arcpy.  That's the ticket.

...by the way, I tried del ArcInfo; del arcpy as an attempt to 'un-initialize' and that didn't work...ending the thread in order to start a new one killed the process effectively.

Hope that helps,
Wayne
0 Kudos
by Anonymous User
Not applicable
I just tried as a complete stand alone script and it still fails with the "tool is not licensed" error.  The first snippet I posted was  also "stand alone" as I was using the IDLE interactive window, not the python window within ArcCatalog or ArcMap (with no Arc sessions open).

from the help docs:

Tip:

The setting of the product and extensions is only necessary within stand-alone scripts. If you are running tools from the Python window or using script tools, the product is already set from within the application, and the active extensions are based on the Extensions dialog box.


I do not know how to "un-initialize" ArcEditor.

import arcinfo
import arcpy

arcpy.SetProduct('ArcInfo')
arcpy.ProductInfo()

cb = r'C:\TEMP\UtilityTest.gdb\Stm_Cb'
mh = r'C:\TEMP\UtilityTest.gdb\Stm_Mh'

arcpy.Near_analysis(cb, mh)
print 'done'


I tried to just start with importing arcinfo again and that fails no matter what, unless I import arceditor first.  I think I am missing something here...It just seems to default to ArcEditor no matter what...There has got to be a way outside of going into our ArcGIS Administrator and explicitly change to ArcInfo there...I want to avoid that since this ArcInfo license will be shared between 6 people.
0 Kudos
WilliamCraft
MVP Regular Contributor
Caleb, I noticed in your initial post that the arcpy.CheckProduct('ArcInfo') line toward the bottom yields a return of u'Unavailable'.  Could it be that that the ArcInfo license is already in use by someone else at the moment?  I believe that if a license is not or cannot be explicitly set (possibly due to it not being currently available), then the license initialized will be issued using the highest available license level at that time.  In your case, perhaps the ArcEditor is simply the "next best" available license which isn't suitable for the tool you're trying to run.  Do you think this could be the issue?
0 Kudos
by Anonymous User
Not applicable
Thanks William...Yeah I think the license is indeed in use somehow because I tried this as a batch file:

cd C:\Program Files (x86)\ArcGIS\Desktop10.0\Bin
SET ESRI_SOFTWARE_CLASS=Professional
arcmap


And when it starts to open ArcMap at the ArcInfo level, I get the message that all ArcInfo licenses are in use.  However, no one in our department is using it right now.  My guess is the GIS Manager maybe set his license to ArcInfo for testing after he upgraded our license manager this weekend and forgot to switch back to ArcEditor.  He is out of the office today so I think I'll have to wait till tomorrow to get to the bottom of this.  Thanks William and Wayne!
0 Kudos