Search code examples
pythonpython-2.7arcgisarcpy

How can I check multiple extensions in arcpy and print an interesting statement?


I'm trying to check if three extensions are available in arcpy. How can I return a statement listing the extensions that are available?

import arcpy

if arcpy.CheckExtension("3D, Network, Spatial") == "Available":
print "These extensions are available.."
else:
    raise LicenseError

except LicenseError:
   print("license is unavailable")

Solution

  • I did the following:

    availLicense = []
    
    if arcpy.CheckExtension("3D") == "Available":
        availLicense.append("ArcGIS 3D Analyst")
    if arcpy.CheckExtension("Network") == "Available":
        availLicense.append("ArcGIS Network Analyst")
    if arcpy.CheckExtension("Spatial") == "Available":
        availLicense.append("ArcGIS Spatial Analyst")
    
    print "The following extensions are available: " + str(availLicense).strip('[]')
    

    Output looks like this:

    The following extensions are available: 'ArcGIS 3D Analyst', 'ArcGIS Network Analyst', 'ArcGIS Spatial Analyst'