Select to view content in your preferred language

Signing into ArcPro via python to access arcpy module

1783
11
12-22-2023 10:02 AM
GrantSmith122
Occasional Contributor

Hello, I am having an issue with accessing the arcpy module of my ArcPro's default python environment. I am trying to run a standalone python script that will be initiated by a service account via Task Scheduler. Whenever I use the python 3.7.11 environment to run the script, it fails out when trying to access the arcpy module, saying "Error: The Product License has not been initialized."

I can successfully run the script using an old ArcDesktop python instance (2.7.18.4), though that is not a long term solution since there are other modules that I would like to add to the script in order to increase the script functionality (these modules are not compatible with 2.7.18.4).

The only solution I can think of is trying to have the script authenticate my ArcPro account at the outset of the script, thereby 'unlocking' the 3.7.11 version of arcpy and also allowing me to use the additional modules that I would like.

NOTE: I don't need to post data to AGOL or an Enterprise Portal, so I don't think the ArcGIS API for Python is applicable, but I could be mistaken. I just need to sign into Pro in order to access a python 3 environment.

Does anyone know how this could be accomplished?

0 Kudos
11 Replies
DonMorrison1
Frequent Contributor

When I run code from the Task Scheduler, I run it on a machine with a ArcGIS Pro "single use license".   Give that a try to see if it helps. 

0 Kudos
Raul
by
Regular Contributor

This is an issue that has long plagued me and other developers, see:

https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-runtime-error-the-product-license-has/...

Like @DonMorrison1, the best solution for running python scripts on the task scheduler is to do so either with an user with single use or concurrent license (as long as there's at least one available).

My "solution" for environments where I only have access to named user licenses is to manually sign out and sign in the named user from arcgis pro periodically.

0 Kudos