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
Solved! Go to Solution.
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!
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!
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
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.
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
Step 2: Caching local user (src: https://community.esri.com/t5/python-questions/arcpy-fails-to-import-when-not-logged-into-host-machi...)
Step 3: Just in case… (src: https://community.esri.com/t5/arcgis-pro-questions/running-a-scheduled-task-on-a-server-machine/m-p/...)
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.
I have not had a chance to implement this yet.
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.
This worked great! Thanks.
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:
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: