我正在尝试在 SLES 11P1 上的 Apache 下运行 MoinMoin。当有人尝试访问该网站时,我的 Apache 日志中出现以下错误:
mod_wsgi (pid=20772): Target WSGI script '/srv/www/wiki/moin.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=20772): Exception occurred processing WSGI script '/srv/www/wiki/moin.
wsgi'.
Traceback (most recent call last):
File "/srv/www/wiki/moin.wsgi", line 44, in <module>
from MoinMoin.web.serving import make_application
File "/usr/local/lib64/python2.6/site-packages/MoinMoin/web/serving.py", line 14, in <module>
from MoinMoin import version, log
File "/usr/local/lib64/python2.6/site-packages/MoinMoin/log.py", line 92, in <module>
import logging.config
File "/usr/lib/python2.6/logging/config.py", line 30, in <module>
import sys, logging, logging.handlers, string, socket, struct, os, traceback, types
File "/usr/lib/python2.6/logging/handlers.py", line 27, in <module>
import logging, socket, types, os, string, cPickle, struct, time, re
ImportError: /usr/lib64/python2.6/lib-dynload/cPickle.so: undefined symbol: PyUnicodeUCS2_DecodeUTF8
但是,如果我从 Python 解释器手动执行失败的语句,则没有问题:
$ python
'import site' failed; use -v for traceback
Python 2.6.6 (r266:84292, Feb 17 2011, 08:36:48)
[GCC 4.3.4 [gcc-4_3-branch revision 152973]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging, socket, types, os, string, cPickle, struct, time, re
>>>
在 Apache 下运行但在命令行运行 Python 时不会导致该错误的原因是什么?
编辑:看起来他们正在访问不同的共享库。 Apache 正在运行/usr/lib64/python2.6/lib-dynload/cPickle.so
,我在命令行调用的 Python 解释器也正在运行/usr/lib/python2.6/lib-dynload/cPickle.so
$ python -v
...
>>> import cPickle
dlopen("/usr/lib/python2.6/lib-dynload/cPickle.so", 2);
dlopen("/usr/lib/python2.6/lib-dynload/cStringIO.so", 2);
答案1
正如您所注意到的,当您从命令行执行不同的 python 二进制文件时,Apache(64 位)正在加载不同的库。修复 Python2.6 64 位安装的二进制文件/库。这应该会消失。