1

为了让 mod_wsgi 在 CentOS 5.4 上运行,我按照此处的说明添加了 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 安装的命令行并尝试“导入 Django”时,找不到该模块(ImportError)。但是,我的默认 Python 2.4 安装(仍然可以正常工作)能够成功导入。如何将 Python 2.6 指向 Django?

4

2 回答 2

0

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

于 2010-03-27T23:52:13.957 回答
0

我创建了一个链接文本,记录了我让 Django 在 Redhat 和 CentOS 上工作的经历。我升级了我正在使用的 python 版本并从 init.d 脚本开始。

于 2010-04-05T08:48:49.907 回答