title: How to properly install isapi_wsgi on IIS for Python2.7?
body: <p>I've worked through installing Python as a CGI application on IIS on Windows 7. This is pretty straightforward, but I'd like to use the WSGI stuff, for better flexibility. </p>
  
  <p>I downloaded the archive for <a href="http://code.google.com/p/isapi-wsgi" rel="noreferrer">isapi_wsgi</a>, unzipped it, and then ran the install as per <a href="http://code.google.com/p/isapi-wsgi/wiki/InstallationInstructions" rel="noreferrer">the instructions</a>, like this: </p>
  
  <pre><code>\python27\python.exe setup.py install
  </code></pre>
  
  <p>This succeeded: </p>
  
  <p><img src="https://i.stack.imgur.com/uX9I9.png" alt="enter image description here"></p>
  
  <p>Then I coded a .py module that had the wsgi glue in it, and tried installing it.  This failed like so: </p>
  
  <p><img src="https://i.stack.imgur.com/GFdiF.png" alt="enter image description here"> </p>
  
  <p>It's a COM Moniker error, and I know that the IIS6-compatible management stuff is based on COM Monikers, which reminded me that there is a pre-req for isapi_wsgi of the IIS6-compatible management stuff. I ran <code>\windows\system32\OptionalFeatures.exe</code> and installed that, then re-ran the .py module and it installed correctly.  </p>
  
  <pre><code>C:\dev\wsgi&gt;\Python27\python.exe app1_wsgi.py
  Configured Virtual Directory: /wsgi
  Installation complete.
  </code></pre>
  
  <p>Ok, wonderful.  Now when I look in the current directory, I see a new DLL named _app1_wsgi.dll, and when I look in IIS Manager I can see a new IIS vdir, and a scriptmap within that vdir for '*', which is mapped to the _app1_wsgi.DLL.  All good.  But! making a request to <code><a href="http://localhost/wsgi" rel="noreferrer">http://localhost/wsgi</a></code> gives me a 500 error.</p>
  
  <p>Through some trial-and-error I see that the .py module that defines my handlers <em>must be in the site-packages</em> directory.  I am very surprised by this. </p>
  
  <p>Can I avoid this?  Can I simply put the .py module in the same directory as the generated .dll file?  Or do I need to deploy all of my python logic to site-packages in order to run it from the WSGI mechanism? </p>