配置不正确:导入中间件时出错indivo_server.indivo.middlewares.authentication:"无法导入名称HTTPRequest

时间:2016-01-18 13:35:49

标签: python django wsgi django-settings

我正在ubuntu 14.10上使用Indivohealth构建概念验证。我用Mysql安装了服务器和UI。

http://indivo.smartrx.in:8002 - UI服务器网址

http://indivo.smartrx.in:8001 - Indivo服务器网址[显示内部服务器错误,下面给出的是日志]

 [Mon Jan 18 12:48:23.888096 2016] [:error] [pid 28663] [client IP:39138] mod_wsgi (pid=28663): Exception occurred processing WSGI script '/var/www/html/sample/indivo_server/django.wsgi'.
    [Mon Jan 18 12:48:23.888199 2016] [:error] [pid 28663] [client IP:39138] Traceback (most recent call last):
    [Mon Jan 18 12:48:23.888253 2016] [:error] [pid 28663] [client IP:39138]   File "/var/www/html/sample/indivo_server/django.wsgi", line 40, in __call__
    [Mon Jan 18 12:48:23.888399 2016] [:error] [pid 28663] [client IP:39138]     return self.application(environ, _start_response)
    [Mon Jan 18 12:48:23.888435 2016] [:error] [pid 28663] [client IP:39138]   File "/var/www/html/sample/indivo_env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
    [Mon Jan 18 12:48:23.888631 2016] [:error] [pid 28663] [client IP:39138]     self.load_middleware()
    [Mon Jan 18 12:48:23.888673 2016] [:error] [pid 28663] [client IP:39138]   File "/var/www/html/sample/indivo_env/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
    [Mon Jan 18 12:48:23.888950 2016] [:error] [pid 28663] [client IP:39138]     raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
    [Mon Jan 18 12:48:23.888998 2016] [:error] [pid 28663] [client IP:39138] ImproperlyConfigured: Error importing middleware indivo_server.indivo.middlewares.authentication: "cannot import name HTTPRequest"


Indivo_server - settings.py ->> 

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'indivo_server.indivo.middlewares.authentication.Authentication',
    'indivo_server.indivo.middlewares.paramloader.ParamLoader',
    'indivo_server.indivo.middlewares.authorization.Authorization',
    'indivo_server.indivo.middlewares.audit.AuditWrapper'
)

我有文件夹indivo,即/ var / www / html / sample / indivo_server / indivo,它包含所有中间件和其他文件夹。

我想解决的问题:

  1. 无法使用johnsmith@example.org / jsmith / password.example在UI服务器上登录
  2. Indivo服务器问题
  3. 我花了3天多的时间来设置,有一天在这个问题上请帮我解决这些问题。

    非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我的sys.path还有系统范围的python路径,所以我删除了这些路径,只保留了virtualenv路径。之后我在.pth文件中添加模块路径并保存在“site-packages”环境文件夹下。问题解决了。 : - )