Problem Install and Run psycopg2 + Windows + Apache2 + mod_wsgi
<p>1) I try to setup a new web environment to host python + psycopg2 code. Here are my steps :</p>

<p>2) Download <a href="http://modwsgi.googlecode.com/files/mod_wsgi-win32-ap22py26-3.0.so" rel="nofollow">http://modwsgi.googlecode.com/files/mod_wsgi-win32-ap22py26-3.0.so</a></p>

<p>3) Copy mod_wsgi-win32-ap22py26-3.0.so to C:\Program Files\Apache Software Foundation\Apache2.2\modules,
and rename it as mod_wsgi.so</p>

<p>Add the following new lines into <strong><em>C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf</em></strong></p>

<pre><code>LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /wsgi/ "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/wsgi/"
</code></pre>

<p>4) Save a file named <strong><em>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\wsgi\myapp.py</em></strong> with the following content :</p>

<pre><code>def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]
</code></pre>

<p>5) Access using <strong><em>http://localhost/wsgi/myapp.py</em></strong></p>

<p>6) Install <a href="http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.0.13.win32-py2.6-pg8.4.1-release.exe" rel="nofollow">http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.0.13.win32-py2.6-pg8.4.1-release.exe</a></p>

<p>7) If I modify the file content to</p>

<pre><code>import psycopg2

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]
</code></pre>

<p>I will get</p>

<p><em><strong>ImportError: No module named psycopg2</em></strong></p>

<p>How can I tell apache, I had install the psycopg2 module in C:\Python26</p>

<p>8) I run the following standalone script to show psycopg2 had been installed.</p>

<pre><code>import psycopg2

print "Hello, World!"
</code></pre>

<p>I run it using</p>

<pre><code>C:\Documents and Settings\yan-cheng.cheok\Desktop&gt;mypython.py
Hello, World!
</code></pre>

<p>Seem my python environment is OK.</p>
