Setting up django on apache (mod_wsgi, virtualenv) -


i'm putting django site in production first time please forgive ignorance.

i'm trying put django site on apache. i've read documentation mod_wsgi , tried simple hello world configured ok. problem i'm having seems using virtualenvs it. wanna set things including virtualenvs , i'm ready future sites.

to problem now.

the error i'm getting in apache log is:

no module named django.core.handlers.wsgi 

so seems not reading virtualenvs properly.

this wsgi script:

import os import sys import site site.addsitedir('/home/user/.virtualenvs/myapp/lib/python2.7/site-packages')  path = '/home/user/django/myapp/myapp' if path not in sys.path:     sys.path.append(path)  sys.stdout = sys.stderr print sys.path  os.environ['django_settings_module'] = 'myapp.settings'  import django.core.handlers.wsgi application = django.core.handlers.wsgi.wsgihandler() 

and error log apache. printed out sys.path can see looks like.

[tue jun 05 14:54:07 2012] [error] ['/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/pil', '/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info', '/home/user/.virtualenvs/myapp/lib/python2.7/site-packages', '/home/user/django/myapp/myapp'] [tue jun 05 14:54:07 2012] [error] [client 127.0.0.1] mod_wsgi (pid=1039): target wsgi script '/srv/http/wsgi_scripts/myapp.wsgi' cannot loaded python module. [tue jun 05 14:54:07 2012] [error] [client 127.0.0.1] mod_wsgi (pid=1039): exception occurred processing wsgi script '/srv/http/wsgi_scripts/myapp.wsgi'. [tue jun 05 14:54:07 2012] [error] [client 127.0.0.1] traceback (most recent call last): [tue jun 05 14:54:07 2012] [error] [client 127.0.0.1]   file "/srv/http/wsgi_scripts/myapp.wsgi", line 17, in <module> [tue jun 05 14:54:07 2012] [error] [client 127.0.0.1]     import django.core.handlers.wsgi [tue jun 05 14:54:07 2012] [error] [client 127.0.0.1] importerror: no module named django.core.handlers.wsgi 

if have suggestions or had similar issue please help.

thanks

you haven't added actual virtualenv site-packages directory mix. try:

import site site.addsitedir('/path/to/your/virtualenv/lib/python2.x/site-packages') # `x` specific version 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -