I'm setting up Django with apache, mod_wsgi, virtual env
I have a virtual env that I want to use here: [Missleading name - long story!] /home/andy/Dev/python/async-mongo/
I downloaded mod_wsgi and compiled it with virtual_env as root
./configure --with-python=/home/andy/Dev/python/async-mongo/bin/python
I ran as root:
make install
I setup WSGIPythonHome & Path in http.conf
WSGIPythonHome /home/andy/dev/python/async-mongo/
WSGIPythonPath /home/andy/dev/python/async-mongo/lib/python2.6/site-packages
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
I think I followed the instructions at http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
When I run the 'Hello World' app it works
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]
When I try to import a module it fails:
import sys; raise Exception(sys.path)
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)
print >> sys.stderr, 'sys.prefix = %s' % repr(sys.prefix)
print >> sys.stderr, 'sys.path = %s' % repr(sys.path)
return [output]
The error I see in the apache logs is:
[Fri Mar 30 15:09:53 2012] [notice] Apache/2.2.20 (Ubuntu) mod_wsgi/3.3 Python/2.6.7 configured -- resuming normal operations
........
Exception: ['/home/andy/dev/python/async-mongo', '/home/andy/dev/python/async-mongo/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg', '/home/andy/dev/python/async-mongo/lib/python2.6/site-packages/pip-1.0.2-py2.6.egg', '/home/andy/dev/python/async-mongo/lib/python2.6/site-packages/txmongo-0.3-py2.6-linux-i686.egg', '/home/andy/dev/python/async-mongo/lib/python2.6', '/home/andy/dev/python/async-mongo/lib/python2.6/plat-linux2', '/home/andy/dev/python/async-mongo/lib/python2.6/lib-tk', '/home/andy/dev/python/async-mongo/lib/python2.6/lib-old', '/home/andy/dev/python/async-mongo/lib/python2.6/lib-dynload', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/home/andy/dev/python/async-mongo/lib/python2.6/site-packages']
I am guessing that somewhere somehow I am still referencing the old system level python but I can not understand where. How can I fix this?