setchock
setchock

Reputation: 151

WSGI: Django App is not getting the required site-packages

Unfortuanetely I am stuck with my Website returning a 500 error.

The apache log is not really specific, and so I do not really know what to do. Before some apt-get upgrades everything worked fine.

I do think this might be a permission error. How do I have to set the permissions working with WSGI?

Or do you know why this problem could be occuring for another reason?

apache conf:

...
WSGIDaemonProcess aegee-stuttgart.org  python-path=/home/sysadmin/public_html/aegee-stuttgart.org:/home/sysadmin/.virtualenvs/django/lib/python2.7
    WSGIProcessGroup aegee-stuttgart.org
    WSGIScriptAlias / /home/sysadmin/public_html/aegee-stuttgart.org/aegee/wsgi.py
...

wsgi.py:

...
import os, sys

# add the aegee project path into the sys.path
sys.path.append('/home/sysadmin/public_html/aegee-stuttgart.org/aegee')

# add the virtualenv site-packages path to the sys.path
sys.path.append('/home/sysadmin/.virtualenvs/django/lib/python2.7/site-packages')
import django
from django.core.handlers.wsgi import WSGIHandler
...

error.log:

mod_wsgi (pid=23202): Exception occurred processing WSGI script '/home/sysadmin/p$
Traceback (most recent call last):
 File "/home/sysadmin/public_html/aegee-stuttgart.org/aegee/wsgi.py", line 31, i$
   return super(WSGIEnvironment, self).__call__(environ, start_response)
 File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 189,$
   response = self.get_response(request)
 File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 218,$
   response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
 File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 264,$
   if resolver.urlconf_module is None:
 File "/usr/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 395, $
   self._urlconf_module = import_module(self.urlconf_name)
 File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
   __import__(name)
 File "/home/sysadmin/public_html/aegee-stuttgart.org/aegee/urls.py", line 8, in$
   from .userprofile.views import AccountPersonalInfoView
 File "/home/sysadmin/public_html/aegee-stuttgart.org/aegee/userprofile/views.py$
   from django.contrib.auth.mixins import LoginRequiredMixin
ImportError: No module named mixins

Upvotes: 0

Views: 364

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58543

Use:

WSGIDaemonProcess aegee-stuttgart.org python-home=/home/sysadmin/.virtualenvs/django python-path=/home/sysadmin/public_html/aegee-stuttgart.org

not what you had. It is possible to use python-path to refer to a virtual environment, but you were using the wrong directory. Use python-home instead and set it to same directory as sys.prefix gives for the virtual environment.

Because you were using wrong directory, it was picking up Django from main Python installation and not the virtual environment.

Upvotes: 1

Related Questions