代码之家  ›  专栏  ›  技术社区  ›  Swizec Teller

Django mod_python部署错误

  •  0
  • Swizec Teller  · 技术社区  · 15 年前

    我正试图通过mod_python部署一个django项目,我一直收到一个错误消息,说缺少一个处理程序模块。

    我的Apache配置:

        <Location />
                SetHandler python-program
                PythonHandler django.core.handlers.modpython
                SetEnv DJANGO_SETTINGS_MODULE bookmarklet_server.settings
                PythonOption django.root /
                PythonDebug On
                #PythonPath "['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']"
        </Location>
    

    另一条路径是我试图复制默认的pythonpath,但没有帮助。

    python控制台中的一个快速测试显示模块应该是可访问的:

    python 2.6.4(r264:75706,2009年11月2日,14:44:17) [GCC 4.4.1]关于Linux2 有关详细信息,请键入“帮助”、“版权”、“信用”或“许可证”。

    >>>导入django.core.handlers.modpython

    无错误

    但是,加载站点时,会意外返回此错误:

    MOD_PYTHON ERROR
    
    ProcessId:      8926
    Interpreter:    '<ip>'
    
    ServerName:     '<ip>'
    DocumentRoot:   '/htdocs'
    
    URI:            '/'
    Location:       '/'
    Directory:      None
    Filename:       '/htdocs'
    PathInfo:       '/'
    
    Phase:          'PythonHandler'
    Handler:        '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 1202, in     _process_target
        module = import_module(module_name, path=path)
    
      File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 304, in import_module
        return __import__(module_name, {}, {}, ['*'])
    
    ImportError: No module named django.core.handlers.modpython
    
    2 回复  |  直到 15 年前
        1
  •  0
  •   lprsd    15 年前

    也许姜戈不在你的便池里?

        2
  •  0
  •   Swizec Teller    15 年前

    好的,设法解决了问题。

    这个特别的进口问题是由 安装 Django而不仅仅是将SVN主干链接到dist包中。我不知道为什么这对服务器进程不起作用。

    但是,通过nginx进行cgi部署解决了更多的问题,最后一个问题(也使我的wsgi部署尝试失败)是我的/home dir(文件所在位置)只能由我自己访问。

    我今天学到了很多。)