【问题标题】:Make Python 2.6 see Django让 Python 2.6 看到 Django
【发布时间】:2011-02-01 15:32:44
【问题描述】:

为了让 mod_wsgi 在 CentOS 5.4 上运行,我在 instructions here 之后添加了 Python 2.6 作为可选库。配置看起来不错,只是在尝试 ping 服务器时 Apache 日志会打印此错误:

mod_wsgi (pid=20033, process='otalo', application='127.0.0.1|'): Loading WSGI script '...django.wsgi'. 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] mod_wsgi (pid=20033): Target WSGI script '...django.wsgi' cannot be loaded as Python module. 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] mod_wsgi (pid=20033): Exception occurred processing WSGI script '...django.wsgi'. 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] Traceback (most recent call last): 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218]   File "...django.wsgi", line 8, in <module> 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218]     import django.core.handlers.wsgi 
[Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] ImportError: No module named django.core.handlers.wsgi

当我转到 python2.6 安装的命令行并尝试“import Django”时,找不到该模块 (ImportError)。但是,我的默认 Python 2.4 安装(仍然可以正常工作)能够成功导入。如何将 Python 2.6 指向 Django?

【问题讨论】:

    标签: python django centos mod-wsgi


    【解决方案1】:

    您需要专门为要使用它的 Python 版本安装 Django——2.4 和 2.6 的安装总是分开的(它们必须是——二进制和字节码格式不兼容!) .我不知道 CentOS 提供了哪些可能性(如果有的话)——我会得到 Django 的 sources 并从源代码安装(归结为:下载、tar、cd,最后是一个简单的 sudo python2.6 setup.py install——或者您运行 Python 的 2.6 安装)。作为一个比系统管理员更好的开发人员,我总是倾向于从源代码安装我正在做的真正核心的东西(尤其是 Python 版本和扩展)。

    【讨论】:

    • 成功了,谢谢!按照同样的逻辑,我现在必须返回并安装其他 python 插件以进行并行安装(MySQLdb、wadofstuff 序列化程序等)
    【解决方案2】:

    我写了一篇 link text 来记录我让 Django 在 Redhat 和 CentOS 上工作的经历。我升级了我正在使用的 python 版本并从 init.d 脚本开始。

    【讨论】:

      猜你喜欢
      • 2010-09-14
      • 2011-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多