如果我运行python manage.py runserver,它运行正常。但是,当我尝试让我的网站运行apache时,我不断收到错误:
mod_wsgi (pid=25005): Exception occurred processing WSGI script '/apps/peer-web/peer_web/wsgi.py'.
Traceback (most recent call last):
File "/apps/peer-web-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
self.load_middleware()
File "/apps/peer-web-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "datetime initialization failed"
mod_wsgi (pid=25005): Exception occurred processing WSGI script '/apps/peer-web/peer_web/wsgi.py'.
Traceback (most recent call last):
File "/apps/peer-web-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
self.load_middleware()
File "/apps/peer-web-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "cannot import name utils"
编辑:重新安装Django后的新追踪
mod_wsgi (pid=25005): Exception occurred processing WSGI script '/apps/peer-web/peer_web/wsgi.py'.
Traceback (most recent call last):
File "/apps/peer-web-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
self.load_middleware()
File "/apps/peer-web-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "cannot import name utils"
mod_wsgi (pid=25005): Exception occurred processing WSGI script '/apps/peer-web/peer_web/wsgi.py'.
Traceback (most recent call last):
File "/apps/peer-web-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
self.load_middleware()
File "/apps/peer-web-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "cannot import name utils"
我该如何解决这个问题?
答案 0 :(得分:4)
由于我使用的是Amazon Linux EC2实例,因此我忘记了使用mod_wsgi
配置包安装程序中的安装python2.6
。因此,在使用mod_wsgi
重新安装python2.7
后,它解决了我的问题。
修改强>
要使用python2.7
对其进行配置,请在mod_wsgi
源文件夹中执行以下操作:
./configure --with-python=/usr/bin/python2.7
make install
答案 1 :(得分:0)
请确保将虚拟环境的项目路径和站点包添加到mod_wsgi配置中。
WSGIPythonPath /path/to/mysite.com:/path/to/your/venv/lib/python2.X/site-packages