Chinaunix首页 | 论坛 | 博客
  • 博客访问: 626993
  • 博文数量: 43
  • 博客积分: 1103
  • 博客等级: 少尉
  • 技术积分: 569
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-15 00:04
个人简介

test

文章分类

全部博文(43)

文章存档

2012年(20)

2011年(23)

分类: Python/Ruby

2012-05-16 18:02:01

/etc/httpd/conf.d/python.conf

    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE syslogApp.settings
    PythonPath "['/var/www/html/syslogApp'] + sys.path"
    PythonDebug On

浏览器:

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)

File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1128, in _execute_target
result = object(arg)

File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/modpython.py", line 228, in handler
return ModPythonHandler()(req)

File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/modpython.py", line 191, in __call__
self.load_middleware()

File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 33, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:

File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 269, in __getattr__
self._setup()

File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 40, in _setup
self._wrapped = Settings(settings_module)

File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 75, in __init__
raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)

ImportError: Could not import settings 'djangotest.settings' (Is it on sys.path? Does it have syntax errors?): No module named project.settings
=================
原因是:PythonPath "['/var/www/html/syslogApp'] + sys.path"
不需要加上syslogApp项目的具体目录,只需要上一级的目录.
如下配置即可:
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE syslogApp.settings
    PythonPath "['/var/www/html'] + sys.path"
    PythonDebug On
阅读(5340) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

1471893852012-05-17 21:08:31

这个问题常见吗?