ImportError: No module named django.core.wsgi Apache + VirtualEnv + AWS + WSGI -
ImportError: No module named django.core.wsgi Apache + VirtualEnv + AWS + WSGI -
good eve everyone!
so trying publish site on amazon's ec2 instance, , maintain getting 500 error. dunno why. have been looking @ tutorials, , can't figure why wrong this....
thanks!
//log files
[sun feb 17 23:12:48.066802 2013] mod_wsgi (pid=2102): target wsgi script '/srv/www/app/poka/apache/wsgi.py' cannot loaded python module. [sun feb 17 23:12:48.066840 2013] mod_wsgi (pid=2102): exception occurred processing wsgi script '/srv/www/app/poka/apache/wsgi.py'. [sun feb 17 23:12:48.066864 2013] traceback (most recent phone call last): [sun feb 17 23:12:48.066889 2013] file "/srv/www/mysite/poka/apache/wsgi.py", line 26, in <module> [sun feb 17 23:12:48.066920 2013] django.core.wsgi import get_wsgi_application [sun feb 17 23:12:48.066945 2013] importerror: no module named django.core.wsgi //apache config files
wsgiscriptalias / /srv/www/app/mysite/apache/wsgi.py wsgidaemonprocess mysite python-path=/srv/www/app/mysite:/home/ec2-user/.virtualenvs/mysite-main/lib/python2.7/site-packages wsgiprocessgroup mysite <directory /srv/www/app/mysite/apache/> <files wsgi.py> order deny,allow allow </files> </directory> <directory /srv/www/app/mysite/apache/> order deny,allow allow </directory> <directory /home/ec2-user/app/mysite/static> order deny,allow allow </directory> <directory /home/ec2-user/app/mysite/media> order deny,allow allow </directory> //wsgi.py
import os import sys import site site.addsitedir('/home/ec2-user/.virtualenvs/mysite-main/lib/python2.7/site-packages') os.environ.setdefault("django_settings_module", "mysite.settings") django.core.wsgi import get_wsgi_application application = get_wsgi_application() path = '/srv/www/app/mysite' if path not in sys.path: sys.path.append(path)
i know old thread i've bumped same issue , don't think caused missing package. django core distribution contains right wsgi handler already.
the problem here when wsgi.py executed it's missing packages of site-packages virtualenv. (if have activated virtualenv, , done pip install django fine. have necessary django packages).
as far i'm concerned, fixed issue modifying sys.path in path/to/project/project/wsgi.py file.
you have append project dir , virtualenv site-packages sys.path list. here wsgi.py file contained in project (talking wsgi.py created django-admin.py start-project)... had modify in order create work apache
# ===================== # wsgi.py file begin import os, sys # add together hellodjango project path sys.path sys.path.append('<path_to_my_django_project>/hellodjango') # add together virtualenv site-packages path sys.path sys.path.append('<path_to_virtualenv>/lib/site-packages') # poiting project settings os.environ.setdefault("django_settings_module", "hellodjango.settings") django.core.wsgi import get_wsgi_application application = get_wsgi_application() # wsgi.py file end # =================== make sure:
you added mod_wsgi apache modules dir mod_wsgi must compiled os, apache , python version have
added load module command httpd.conf load mod_wsgi module loadmodule wsgi_module modules/mod_wsgi.so
configured django specifics in httpd.conf or conf include in httpd.conf
based on documentation how utilize django apache , mod_wsgi
wsgiscriptalias / <path_to_project>/hellodjango/hellodjango/wsgi.py wsgipythonpath <path_to_project>:<path_to_virtualenv>/lib/site-packages <directory <path_to_project>/hellodjango/hellodjango> <files wsgi.py> order deny,allow require granted </files> </directory> hope helps. worked me.
django apache amazon-ec2 wsgi django-wsgi
Comments
Post a Comment