Select to view content in your preferred language

ArcGIS Pro Runtime Error: the product license has not been initialized

45739
34
Jump to solution
02-03-2021 10:44 AM
Labels (1)
chintakandel
Regular Contributor

I've issue license initialization in ArcGIS Pro 2.7. I can run python script manually via command line and batch file but encountered with following run time error with scheduled task in Windows server 2019. 

File "C:\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 14, in <module>
import arcgisscripting
File "C:\arcgis\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgisscripting\__init__.py", line 128, in <module>
from ._arcgisscripting import *
RuntimeError: The Product License has not been initialized.

Any ideas or solutions?

Thanks in advance,

Chintamani

34 Replies
feralcatcolonist
Occasional Contributor

I've used this process in the past to trick ArcGIS Pro into thinking that I've manually logged in to keep resetting the counter that requires a manual sign-in process.

import os
import time

#Assign the location on the machine, usually here
ArcGIS_Pro_filepath = r"C:\Program Files\ArcGIS\Pro\bin\ArcGISPro.exe"
#Use os.startfile(), this will launch ArcPro
os.startfile(ArcGIS_Pro_filepath)
#Use time.sleep() to wait 60 seconds, enough time for ArcPro to open properly
time.sleep(60)
#Use os.system() to forcefully quit named process, ArcGISPro.exe
#https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill
os.system("taskkill /f /im ArcGISPro.exe")
#You can use the following output to determine if the command was successful
#SUCCESS: The process "ArcGISPro.exe with PID 4408 has been terminated

https://gist.github.com/FeralCatColonist/9cae407c7200fa6a45f922c019e397c3

jschuckert
Regular Contributor

@feralcatcolonist if you are say using a service account which is what runs all your automation but is rarely logged in with, does this truly keep the ArcGIS Pro login tokens active (or renewed)? A recent ESRI Tech support case we flushed out that their (ESRI's) recommended batch file to launch Pro only works from Task Scheduler if "Run only when user is logged on" is checked. If you use the alternative "Run whether user is logged on or not", it still runs error free however does not make the token refresh calls thus keeping the login active for another 14 days. 

0 Kudos
Shovon
by
New Contributor

Please follow the instructions 

Python in ArcGIS Pro—ArcGIS Pro | Documentation

Authorize Python outside the application
If you run Python scripts that use ArcGIS Pro functionality outside of the ArcGIS Pro application, such as a Python IDE, from a command prompt, or running scripts through scheduled tasks, one of the following conditions must be met:

1.Sign me in automatically is checked when signing in to ArcGIS Pro.
2.ArcGIS Pro is currently open.
3.ArcGIS Pro has been authorized to work offline.
4.ArcGIS Pro is configured with a Concurrent Use license and at least one license is available on the ArcGIS License Manager.

erinheinrich
Occasional Contributor

Option 4 does not work for me, I have use single use licence, concurrent just not working as expected.

0 Kudos
Bryan_krg
Occasional Contributor

I'm not sure if this is how the licensing works but it seems you can check if a license file is present for the user signed into ArcGIS Pro. 
If you look in hidden the folder C:\Users\<your username>\AppData\Local\ESRI_Licensing there is a file called  lss.dat. If this file is present then you will be licensed for arcpy. If it's not there you will not be. The log file in logs tells you when you have created the lss.dat file and what you did to create it.

Bryan_krg_3-1761616493178.png

 

As mentioned above by Shovon there a few criteria that you could meet to create this file. Unfortunately, if your user is running a scheduled task and isn't logged in the options to be signed in or have ArcGIS Pro open are out, which leaves the bottom two. Unfortunately, as erinheinrich mentioned concurrent use license doesn't work as expected either so that leaves 'Authorising ArcGIS Pro to work offline without an internet connection

Bryan_krg_0-1761616133833.png

This will tie up one of your licenses purely for automated tasks which does seem a little crazy. If ESRI could create a python module to allow us get license in the script similar to the functions to checkout extensions it would be greatly appreciated. For example:

if arcpy.CheckProduct("ArcInfo") != "Available":
   try:
      arcpy.SignInToPortal("https://webadaptorhost.domain.com/webadaptorname", 'username', 'password')
      arcpy.CheckOutProduct("ArcInfo")
   else:
     # raise a custom exception
     raise LicenseError

# Do your arcpy scripting things....

 

0 Kudos