Select to view content in your preferred language

Unable to run Python scripts through IIS Server

300
1
Friday
PrayagShah
New Contributor

Hello everyone, 

I am trying to run the webpage using IIS server where users will run the Python scripts from the website. For instance, my website is hosted through IIS, forester can go into one of the webpage and then according to his needs program will start running a calculation process, python file will work in the backend and then display the results. 

But in this process I am facing a problem saying arcgis pro license is not initialized. 

import arcpy

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__in

PrayagShah_1-1732894221294.png

 

Traceback (most recent call last):
File "\\my_server_name\GIS_SSD\python_scripts\Culvert_Size_107a.py", line 21, in <module>
import arcpy
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 77, in <module>
from arcpy.geoprocessing import gp
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from ._base import *
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 14, in <module>
import arcgisscripting
File "E:\ArcGISPro_Python\Python\envs\arcgispro-py3\Lib\site-packages\arcgisscripting\__init__.py", line 131, in <module>
from ._arcgisscripting import *
RuntimeError: The Product License has not been initialized.


However, when I run the same script through the ArcGIS Pro command prompt, it works fine. According to the ArcGIS Pro License Manager, the License Server Status shows "Running" and "Authorized". I have ensured that the application pool for my ArcGIS ProPython.exe file/folder has the proper security rights (using .NET v4.8 Classic). This is the pool I created in IIS Manager.

PrayagShah_0-1732894195890.png

PrayagShah_2-1732894238610.png

I don't understand why the python scripts work fine through the command prompt but do not work through the website. 

 

This is the Python script it generates from the website and works fine locally: E:\ArcGISPro_Python\Python\envs\arcgispro-py3\python.exe \\my_servername.com\GIS_SSD\python_scripts\Culvert_Size_107a.py "2439099.12109375 7616263.95670573" "Culvert_Size_107a.py "2439099.12109375 7616263.95670573""

In my .NET code I have also mentioned the valid python path as shown below 

PrayagShah_3-1732894666993.png

 

Is there any suggestion you all think of? Thank you in advance. 

 

Tags (2)
0 Kudos
1 Reply
Yogesh_Chavan
Frequent Contributor

Hi @PrayagShah,

Have you tried executing this from the website, by keeping an open instance of ArcGIS Pro?

0 Kudos