Recently I thought I'd give Python a try for web development. Configuring it with 64-bit Windows and IIS 7.0 took a bit of trial and error, though, and I didn't find these steps comprehensively laid out anywhere on the web. So here goes:
- Download the 32-bit version of Python 2.6 here. To work with the Python ISAPI filter, it's important you choose the 32-bit variant of the 2.6 version. I accepted all defaults during the installation.
- Download Python ISAPI Extension for IIS 2.6 (pyisapie) here. I unzipped it into a subfolder of C:\Python2.6
- Create an environment variable called PYTHONHOME and set it to where you installed Python, e.g. C:\Python2.6.
- Restart Windows. Since IIS inherits its environment block from services.exe, which cannot be restarted, you need to reboot so the ISAPI filter sees the PYTHONHOME variable.
- Configure IIS to use the ISAPI extension:
- Create a 32-bit application pool (Advanced Settings > Enable 32-Bit Applications = True)
- Create a web site (or application) and configure it to use the application pool you just created
- Add a "Script Map" handler mapping with a request path of "*.py", an executable location of the Python ISAPI DLL (e.g. C:\Python26\PyISAPIe-1.1.0-rc4-Py2.6\PyISAPIe.dll), and any name you'd like. (Accepting Request Restriction defaults is fine.)
- In the home directory of your website, create a Python script to test your handiwork, e.g. a file named page.py with this code:
from Http import *
def Request():
Header("Content-type: text/html")
Write("Hello, World!")
- Visit the URL (e.g. http://website/page.py); if all is well, the message "Hello, world!" appears!