ArcGIS licence not available in Python ?

4020
6
03-31-2016 06:03 AM
KevinCÃ_tÃ_
New Contributor

Hi,

I'm using the Conversion > Polygon to Raster tool in ArcMap and it is working well.

I tried to do a Python script to use this but with a large amount of files, but it says that the tool is not licenced.

Is it possible that some tools are available in ArcMap but not with ArcPy ?

Thanks

0 Kudos
6 Replies
DanPatterson_Retired
MVP Esteemed Contributor

always go to the help topic for tools Polygon to Raster—Help | ArcGIS for Desktop

licensing requirements are listed at the bottom, so either you aren't licensed, or in this case, perhaps you don't have the appropriate extension toggled on in the Customize, Extensions menu option

AdrianWelsh
MVP Notable Contributor

Dan,

For working with extensions in ArcPy, would it be good to always start the scripts off with :

import arcpy

if arcpy.CheckExtension("3D") == "Available":
    arcpy.CheckOutExtension("3D")
else:
    print "3D Analyst license is unavailable"

Or does that mess things up if the license is already checked on in the local desktop ArcMap?

DanPatterson_Retired
MVP Esteemed Contributor

Not if you have it and are working in a single user environment and not one of those share-sy ones.

Accessing licenses and extensions in Python—Help | ArcGIS for Desktop

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 never find any point in checking and getting a nice message, I would rather it fail and a real error message be thrown.

KevinCÃ_tÃ_
New Contributor

Thanks for your answers !

Adrian, I added your code to my script and now it's working ! My extensions were always checked in ArcMap (both Spatial and 3D analyst) but it wasn't working. Now with these 4 lines it works ! Thanks so much!

0 Kudos
RebeccaStrauch__GISP
MVP Esteemed Contributor

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 would say "stand-alone scripts and or custom-tools from these stand-alone scripts".   I find it is always better to check it out (and in at the end, if you want to keep it need) for my custom tools.  In theory, the tools you write should be able to move to other machines, setups and license manager (concurrent or single-use), so better to check it out if needed for your process.  I'm not sure if the second sentence is correct or not (haven't tested).  It may be, assuming a license is available, otherwise you would still get an error, in my opinion.

Adrian Welsh  does a nicer user interface then I use....I just do the checkout since you will still get an error if no licenses/seats are available (lazy coding on my part I guess).  And no, it does not mess up what is already checked out as far as I can tell.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor
if arcpy.CheckExtension("3D") == "Available"
    arcpy.CheckOutExtension("3D")  
else:  
    print "3D Analyst license is unavailable" 

  • Hmmm I prefer that ONLY, if I am distributing to someone working in a 'shared' environment... which happens, never
  • It will fail miserably if associated with a tool in arctoolbox etc. you need to add
    • arcpy.AddMessage("blah blah")
  • Or check for the existence of the tool prior to doing anything and use tool validation etc or simply
    • sys.exit()  # without a message so that it quietly fails since they shouldn't be using it
  • You have to be prepared for ArcGIS PRO etc
    • print("Print is now a function")

As a standalone script, I don't even bother checking since people should read the docs before running anything

0 Kudos