0

我已经用无堆栈 Python 设置了一个 Apache2 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 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

有什么我想念的吗?

4

1 回答 1

1

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

于 2009-12-08T14:35:46.963 回答