Select to view content in your preferred language

Unable to run Python scripts through IIS Server

570
5
Jump to solution
4 weeks ago
PrayagShah
Emerging 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 Solution

Accepted Solutions
PrayagShah
Emerging Contributor

Hi Joshua, 

I think you’re right; the issue was related to IIS permissions. What I did was move the ArcGIS Pro python.exe folder to a different location, then granted permissions to the Application Pool. In the Security list, I also granted permission to IIS_WPG as well.  Now, I can access the Python scripts through the web without any issues.

Thank you everyone for the valuable feedback. 

View solution in original post

0 Kudos
5 Replies
Yogesh_Chavan
Frequent Contributor

Hi @PrayagShah,

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

0 Kudos
PrayagShah
Emerging Contributor

Hi @Yogesh_Chavan

Yes, I did it by keeping the ArcGIS Open but no luck... same error. 

I found one more error that when I open the Python notebook in arcgis pro, I get a message saying " Failed to create notebook server". 

My configuration of this whole thing is like ArcGIS Enterprise 11.3 > Installed ArcGIS Pro > Python environment under C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe

0 Kudos
Yogesh_Chavan
Frequent Contributor

@PrayagShah , have you tried doing this in a cloned environment?

Which version of ArcGIS Pro are you using? Does the failed to open notebooks in Pro is happening for this version of Pro or have been unnoticed yet?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

While ArcGIS Desktop/ArcMap was licensed at the machine level, HKEY_LOCAL_MACHINE (HKLM), ArcGIS Pro is licensed at the user level, HKEY_CURRENT_USER (HKCU).  The ArcGIS Pro license for a user can inherit from a machine-level setting if configured correctly before the user ever launches ArcGIS Pro, but it gets a little trickier once a user has launched ArcGIS Pro at least once, which is the case here.

I have mentioned "user" multiple times, that is because what is important isn't what settings you have for Pro when logged into the IIS server but what settings the credentials running IIS or IIS application pools have for ArcGIS Pro.  Since you have not provided any details about your IIS and application configuration, I can't offer any specifics.  Your issue is in the registry.

0 Kudos
PrayagShah
Emerging Contributor

Hi Joshua, 

I think you’re right; the issue was related to IIS permissions. What I did was move the ArcGIS Pro python.exe folder to a different location, then granted permissions to the Application Pool. In the Security list, I also granted permission to IIS_WPG as well.  Now, I can access the Python scripts through the web without any issues.

Thank you everyone for the valuable feedback. 

0 Kudos