我正在使用 Python Cheetah 进行模板生成,但我无法让它使用_namemapper.so
已安装的编译库。我使用 Cheetah 2.4.3 在安装了 Python 2.4 的 CentOS 5.4 上运行。我无法让 Cheetah 使用_namemapper.so
我在安装期间构建的文件:
Filling conf/asterisk/sip.conf.ect -> conf/asterisk/sip.conf ...
/usr/lib64/python2.4/site-packages/Cheetah/Compiler.py:1508: UserWarning:
You don't have the C version of NameMapper installed! I'm disabling Cheetah's
useStackFrames option as it is painfully slow with the Python version of NameMapper.
You should get a copy of Cheetah with the compiled C version of NameMapper.
NameMapper
但是,我将共享库放在模块旁边:
$ ls -ltr /usr/lib64/python2.4/site-packages/Cheetah/ | grep -i namemap
-rw-r--r-- 1 root root 12376 Jul 1 20:17 NameMapper.py
-rwxr-xr-x 1 root root 36982 Dec 1 09:55 _namemapper.so
-rw-r--r-- 1 root root 12541 Dec 1 09:55 NameMapper.pyc
我尝试将此目录添加到/etc/ld.so.conf.d/python-cheetah.conf
,_namemapper.so
但找不到共享库。
有任何想法吗?
解决了
谢谢@alex-b。结果我在 32 位机器上编译了 Cheetah,并试图在 64 位机器上加载共享库。哦!
>>> from Cheetah._namemapper import NotFound
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: /usr/lib/python2.4/site-packages/Cheetah/_namemapper.so: wrong ELF class: ELFCLASS32
然后我遇到了下一个问题:
>>> from Cheetah._namemapper import NotFound
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: /usr/lib/python2.4/site-packages/Cheetah/_namemapper.so: undefined symbol: PyUnicode_FromFormat
事实证明,Cheetah 在 Python <= 2.6 上运行得不是很好,所以我会升级。