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

17610
30
Jump to solution
02-03-2021 10:44 AM
Labels (1)
chintakandel
New Contributor III

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

1 Solution

Accepted Solutions
Robert_LeClair
Esri Notable Contributor

What type of ArcGIS Pro license are you using?  Named User, Concurrent or Single Use?  I found one case with this messaging where the customer changed the ArcGIS Pro license from Named User to Single Use license - this corrected the error message.  The error could have been thrown if the account running the script has never opened ArcGIS Pro, thus no roaming profile exists.  The analyst and customer tested the workflow using a Single Use license and it worked properly.  Hope this helps!

View solution in original post

30 Replies
Robert_LeClair
Esri Notable Contributor

What type of ArcGIS Pro license are you using?  Named User, Concurrent or Single Use?  I found one case with this messaging where the customer changed the ArcGIS Pro license from Named User to Single Use license - this corrected the error message.  The error could have been thrown if the account running the script has never opened ArcGIS Pro, thus no roaming profile exists.  The analyst and customer tested the workflow using a Single Use license and it worked properly.  Hope this helps!

chintakandel
New Contributor III

Hi Robert, 

Thank you for your suggestion. Worked after running Pro with the account that is used to schedule task to run script.

Thanks,

Chintamani 

NathanHeickLACSD
Occasional Contributor III

Yes, I had a similar issue and just wanted to add my experience to the list.  I had a scheduled task that had been working for a while with no problems.  All of a sudden, I stopped getting email messages from the script.  The script wasn't capturing all exceptions in the code, just those in the main block of business logic.  So, it was not catching this error, which was causing the Scheduled Task to fail with code 2147942401.  Like you, I just opened ArcGIS Pro and signed into a named user account and the script started working.

Could you explain Robert what might have changed?  I haven't logged into ArcGIS Pro on that machine in a while, but it was working a few months ago.

0 Kudos
ThomasLaue1
New Contributor II

 

I’ve been encountering similar issues.  I have found that ArcGIS Pro (which we license through AGOL) automatically logs itself out of every 90 days. I have many Arcpy scripts running via Task Scheduler 24/7.

 

Also, periodically (usually once a day at a specific time) scripts will fail saying “RuntimeError: The Product License has not been initialized.”  No idea what is causing this error as this script runs all day every 30 mins and never gets this error the rest of the day.

 

 

ESRI Tech Support sent me this suggestion which we have yet to implement…

 

 

-------------------------------------------

 

We’ve done a bit of digging into our documentation and might have a solution for you. The bad news is, it doesn’t look like there’s a good way to handle the Pro license refresh through Python. The good news is, there is a promising option for handling it in your environment directly. Please see below for a configuration step-by-step that should solve your logout issue:

 

Step 1: Environmental settings

  1. Convert your Named license to a Single Use license for this instance of Pro (if you haven’t already). See https://pro.arcgis.com/en/pro-app/latest/get-started/convert-named-user-licenses-to-single-use.htm for more details on how to configure this. This should allow offline access for Pro.
  2. Make sure “Sign me in automatically” remains checked when you log into Pro on this machine. Just in case.

 

Step 2: Caching local user (src: https://community.esri.com/t5/python-questions/arcpy-fails-to-import-when-not-logged-into-host-machi...)

  1. Log into the server that will host the script using the username that will be running the script (i.e. the “owner” in task scheduler).
  2. Once logged in, open ArcGIS Pro (this will create an esri profile cookie in your AppData folder, that ArcGIS will be able to use to recognize the user).
  3. Make sure your license and configurations are set according to step 1 and close Pro.

 

Step 3: Just in case… (src: https://community.esri.com/t5/arcgis-pro-questions/running-a-scheduled-task-on-a-server-machine/m-p/...)

  1. If the issue persists after running through steps 1 and 2, it means that your Pro configuration requires the application to be open while running scripts against its library, for whatever reason. If this is the case, and only after completing steps 1 and 2, we recommend you include a task before the script in your task scheduler that will open ArcGIS Pro, to remove any weird library locks. This is an edge case but does appear to affect some users, so I wanted to include it in the outline.

 

 

AlexisHandelman
New Contributor II

Have you implemented these steps and have they worked? We are experiencing the same thing as you. We cannot figure out what is causing Pro to log out. We were trying to avoid converting to single-use license though. 

0 Kudos
ThomasLaue1
New Contributor II

I have not had a chance to implement this yet.

0 Kudos
RobertStevens
Occasional Contributor III

This procedure did nothing.

I ssh to the client windows 10 box, try to run python with arcpy
and still get the same message after having spent 30 mins of my time
going throught the involved procedure of converting to a single
user license.

0 Kudos
Jen_Zumbado-Hannibal
Occasional Contributor

This worked great! Thanks. 

Jen Zumbado-Hannibal, GISP
GIS Coordinator
City of Forest Grove
Forest Grove, OR 97116

by Anonymous User
Not applicable

Our configuration is different than any other helpful threads - here is our config and solution.

Config: We have a dedicated scripting server (WS 2016); default Pro 2.9.1 install; custom cloned environment in "C:\Python3x\...\our_clone"; scripts on local and network drives; tasks run as a domain\service account that we cannot use as machine login; concurrent license

Solution:

  1. Task Manager:
    • General: Run as <domain\service acct>; Whether logged in or not; Highest Privileges (may not be necessary)
    • Action: 
      • Program: C:\Python3x\...\our_clone\python.exe
      • Argument: \\path\\to\\script.py (or c:\path\to\script.py)
    • <everything else default>
  2. ArcPro
    • Right-click application --> more --> run as different user
    • (log in with service account credentials)
    • In the sign-in window, click the configure license settings in the lower left.
      • 2nd time logging in opens Pro - go to Settings\Licensing
    • Change license type to Concurrent and set your license manager
    • Do NOT "Authorize Pro to work offline"

Our biggest problem was initializing the Arc license, which was due to the service account and Pro relationship. Several threads mention logging in as the Scheduled Task user, but that was not possible for us. I often Run As Admin, but had forgotten about the option to log into the application as the service account.   

Other Attempts:

  1. Setting Pro to work offline (I'm very glad this didn't fix our issue because Pro checks the license back in automatically after X period of time - wouldn't work well in our system of automation)
  2. Task manager\Action: "C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\propy"
    • command not recognized.
  3. Task manager\Action: "C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat"
    • successfully recognizes cloned env, but still failed on import arcpy
    • I vaguely recall this command resolving to Pro's env once, so there may be some activation required.
    • as mentioned above, pointing the task directly to the clone's python.exe works and is very clear
  4. Task Manager\Action "Start in" had no affect regardless what path I entered
  5. using batch files with conda activation and python execution