mod_python没有加载无堆栈的Python

时间:2009-12-08 14:13:33

标签: django mod-python python-stackless

我已经使用无堆栈Python设置了Apache2 mod_python环境,它正在运行。 当我使用sys.version测试Python环境时,它会显示

2.5.2 Stackless 3.1b3 060516 (python-2.52:76701, Dec  8 2009, 02:13:34) 
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)]

在浏览器中。

但当我import stackless显示时:

MOD_PYTHON ERROR

ProcessId:      26177
Interpreter:    '127.0.1.1'

ServerName:     '127.0.1.1'
DocumentRoot:   '/var/www/'

URI:            '/test.py'
Location:       None
Directory:      '/var/www/'
Filename:       '/var/www/test.py'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        'mod_python.publisher'

Traceback (most recent call last):

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

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

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

  File "/usr/local/lib/python2.5/site-packages/mod_python/publisher.py", line 204, in handler
    module = page_cache[req]

  File "/usr/local/lib/python2.5/site-packages/mod_python/importer.py", line 1059, in __getitem__
    return import_module(req.filename)

  File "/usr/local/lib/python2.5/site-packages/mod_python/importer.py", line 296, in import_module
    log, import_path)

  File "/usr/local/lib/python2.5/site-packages/mod_python/importer.py", line 680, in import_module
    execfile(file, module.__dict__)

  File "/var/www/test.py", line 1, in <module>
    import stackless

ImportError: No module named stackless


MODULE CACHE DETAILS

Accessed:       Tue Dec  8 08:53:24 2009
Generation:     0

_mp_27cc55c5447f9e0aa13691719290c225 {
  FileName:     '/var/www/test.py'
  Instance:     1 [IMPORT]
  Generation:   0 [ERROR]
  Modified:     Tue Dec  8 08:52:43 2009
}

此外,我无法加载MySQLdb,nltk等。所有这些模块都可以在命令行中加载。所以我的猜测是某种程度上mod_python引用旧的Python安装。

可能是什么问题?


我已经针对无堆栈安装了所有内容。如您所见,我对sys.version的回复是

2.5.2 Stackless 3.1b3 060516 (python-2.52:76701, Dec 8 2009, 02:13:34) [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)]

这是代码的回复:

import sys
def index(req):
  return sys.version

但是,如果我在下面添加import stackless,则会抛出上述错误:

import sys
import stackless
def index(req):
  return sys.version

我有什么遗失的东西吗?

1 个答案:

答案 0 :(得分:1)

mod_python是针对特定版本的Python编译的,只会调用该版本。你可能需要针对Stackless重新编译它,假设这是可能的。