cancel
Showing results for 
Search instead for 
Did you mean: 
Community_Admin
Community Team Member
Community Team Member

Question:

Some users might want to install python on their IIS, for example in order to establish SSO by using python code. How can I install it?

Answer:

In order to do so, follow these steps:

  1. Insure you have CGI installed on your IIS: Go to Start -> Control Panel -> Programs and Features -> on the left hand side, go to "Turn Windows Features on or off" -> Under the IIS node, make sure CGI is installed:
    Community_Admin_5-1634238938573.png
  2. Download Python for Windows, from python.org (doesn't matter 2.7 or python 3, depends on your preference). Make sure you get the x64 version if you have an x64 version of Windows.
  3. Unpack and install that python MSI. Choose the default, which puts python into c:\PythonX (X will be replaced with your Python version)
  4. Create a directory to hold your "development" python scripts. Eg, c:\dev\python
  5. Set the permissions on the files in the directory c:\dev\python to allow IIS to read and execute. Do this by running these two icacls.exe commands from the command line:
    cd \dev\python
    icacls . /grant "NT AUTHORITY\IUSR:(OI)(CI)(RX)"
    icacls . /grant "Builtin\IIS_IUSRS:(OI)(CI)(RX)"
  6. Open the IIS manager, and create a new application. Specify the virtual path as /py and the physical path as c:\dev\python:
    Community_Admin_6-1634238938587.png
    Community_Admin_7-1634238938583.png
  7. Within the new IIS application, add a script map for *.py, and map it to c:\python27\python.exe %s %s:
    Community_Admin_8-1634238938584.png
    Community_Admin_9-1634238938578.png
  8. create a "HelloWorld.py" file in c:\dev\python with this as the content:
    print('Content-Type: text/plain')
    print('')
    print('Hello, world!')
  9. Test that the script is working - invoke in the browser http://localhost/py/helloworld.py

*You should be able to use all Python libraries you have installed on your system.

*In case that you try to open the script and it returns a 502 error, it means that something is wrong in the script. In such cases, debug it on your IDLE instead through the browser

Version history
Last update:
‎10-14-2021 12:17 PM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Need additional support?:

Community Support Request