ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Accessing licenses and extensions in Python

  • Desktop, Engine/Server licenses
  • Extension licenses
  • Licensing functions

Whenever a tool is executed in a script, an ArcGIS license is required. Tools from ArcGIS extensions, such as the ArcGIS Spatial Analyst extension, require an additional license for that extension. If the necessary licenses are not available, a tool fails and returns error messages. For example, if you install with an ArcGIS Desktop Basic license, and you attempt to execute a tool that requires a Desktop Standard or Desktop Advanced license, the tool will fail.

When using an ArcGIS Desktop Basic or Desktop Standard license, a script should set the product to Desktop Basic or Desktop 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.

Every tool checks to ensure it has the appropriate license. If it doesn't have what's required, it fails. To guard against the situation of executing partially through and failing, you can perform a check at the top of your script and fail immediately.

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.

Desktop, Engine/Server licenses

Product modules are imported prior to the import of arcpy to define the desktop license used by a script. The CheckProduct function can be used to check the availability of desktop licenses, while the ProductInfo function reports what the current product license is.

Legacy:

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

Extension licenses

Licenses for extensions can be retrieved from a license manager and returned once they are no longer needed. CheckExtension is used to see if a license is available to be checked out for a specific type of extension, while CheckOutExtension actually retrieves the license. Once the extension license has been retrieved by the script, extension tools can be executed. Once a script is done using tools from a particular extension, the CheckInExtension function should be used to return the license to the license manager so other applications can use it. All checked-out extension licenses and set product licenses are returned to the license manager when a script completes.

The following example executes some ArcGIS 3D Analyst tools and sets the desktop product license to ArcGIS Desktop Basic, since an ArcGIS Desktop Advanced license is not required to execute tools from an extension. The script will fail if the ArcGIS Desktop Basic license is not explicitly set and no ArcGIS Desktop Advanced license is available, since a desktop license is required to execute extension tools.

class LicenseError(Exception):
    pass

# Set desktop license used to Basic (keyword is arcview)
#
import arcview
import arcpy

try:
    if arcpy.CheckExtension("3D") == "Available":
        arcpy.CheckOutExtension("3D")
    else:
        # Raise a custom exception
        #
        raise LicenseError
    
    arcpy.env.workspace = "D:/GrosMorne"
    arcpy.HillShade_3d("WesternBrook", "westbrook_hill", 300)
    arcpy.Aspect_3d("WesternBrook", "westbrook_aspect")

except LicenseError:
    print("3D Analyst license is unavailable")
except arcpy.ExecuteError:
    print(arcpy.GetMessages(2))
finally:
    # Check in the ArcGIS 3D Analyst extension
    #
    arcpy.CheckInExtension("3D")

In the above example, the ArcGIS 3D Analyst extension is checked in under a finally clause, ensuring that the extension is always checked back in, whether an exception has occurred or not.

A returned value of Failed, Unavailable, or NotLicensed indicates that the extension could not be successfully checked out.

Below are the extension names and their extension code names:

ExtensionExtension Code

ArcGIS 3D Analyst extension

3D

ArcGIS Data Interoperability extension for Desktop

DataInteroperability

ArcGIS Data Reviewer Desktop

Datareviewer

ArcGIS Aviation Airports

Airports

ArcGIS Aviation Charting

Aeronautical

ArcGIS Bathymetry

Bathymetry

ArcGIS Maritime

Nautical

ArcGIS Geostatistical Analyst extension

GeoStats

ArcGIS Network Analyst extension

Network

ArcGIS Spatial Analyst extension

Spatial

ArcGIS Schematics extension

Schematics

ArcGIS Tracking Analyst extension

Tracking

ArcGIS Workflow Manager (Classic) Desktop

JTX

ArcScan

ArcScan

ArcGIS Business Analyst

Business

ArcGIS Defense Mapping

Defense

ArcGIS Production Mapping

Foundation

ArcGIS Roads and Highways

Highways

StreetMap

StreetMap

Product code names

Product Codes

ArcView (equivalent to an ArcGIS Desktop Basic license)

ArcEditor (equivalent to an ArcGIS Desktop Standard license)

ArcInfo (equivalent to an ArcGIS Desktop Advanced license)

Engine

EngineGeoDB

ArcServer

Licensing functions

FunctionExplanation

CheckExtension(extension)

Checks to see if a license is available to be checked out for a specific type of extension.

Return ValueMeaning

Available

The requested license is available to be set.

Unavailable

The requested license is unavailable to be set.

NotLicensed

The requested license is not valid.

Failed

A system failure occurred during the request.

CheckInExtension(extension)

Returns the license so other applications can use it.

Return ValueMeaning

NotInitialized

No desktop license has been set.

Failed

A system failure occurred during the request.

CheckedIn

The license has been returned successfully.

CheckOutExtension(extension)

Retrieves the license.

Return ValueMeaning

NotInitialized

No desktop license has been set.

Unavailable

The requested license is unavailable to be set.

CheckedOut

Successfully set the license.

CheckProduct(code)

Checks to see if the requested license is available.

Return ValueMeaning

AlreadyInitialized

License has already been set in the script.

Available

The requested license is available to be set.

Unavailable

The requested license is unavailable to be set.

NotLicensed

The requested license is not valid.

Failed

A system failure occurred during the request.

ProductInfo()

Returns the current product license.

Return ValueMeaning

NotInitialized

No license has been set.

ArcInfo

An ArcGIS Desktop Advanced license has been set.

ArcEditor

An ArcGIS Desktop Standard license has been set.

ArcView

An ArcGIS Desktop Basic license has been set.

ArcServer

An ArcGIS Server license has been set.

EngineGeoDB

An EngineGeoDB license has been set.

Engine

An Engine license has been set.

SetProduct(code)

Defines the desktop license.

Return ValueMeaning

CheckedOut

Successfully set the license.

AlreadyInitialized

License has already been set in the script.

NotLicensed

The requested license is not valid.

Failed

A system failure occurred during the request.

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal