WSGI:Django 应用程序未获取所需的站点包

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

不幸的是,我的网站一直返回 500 错误。

apache 日志不是很具体,所以我真的不知道该怎么做。在一些 apt-get 升级之前一切正常。

我认为这可能是权限错误。我必须如何设置使用 WSGI 的权限?

或者您知道为什么会出现此问题的其他原因吗?

apache 配置文件:

...
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

使用:

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

不是你所拥有的。可以使用 python-path 来指代虚拟环境,但您使用了错误的目录。请改用 python-home 并将其设置为与 sys.prefix 为虚拟环境提供的目录相同的目录。

因为您使用了错误的目录,它是从主 Python 安装而不是虚拟环境中选择 Django。