"在Windows上如何获取并安装Python 2.7的_namemapper.pyd文件"

2024-06-18 13:11:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我用Cheetah在windows系统上安装了Python 2.7。下面是我在尝试将cheetah.template对象与.tmpl文件一起使用时遇到的错误。

from Cheetah.Template import Template
t = Template(file='home.tmpl')
C:\wamp\bin\Python27\lib\site-packages\Cheetah\Compiler.py:1509: UserWarning:
You don't have the C version of NameMapper installed! I'm disabling Cheetah's us
eStackFrames option as it is painfully slow with the Python version of NameMappe
r. You should get a copy of Cheetah with the compiled C version of NameMapper.
  "\nYou don't have the C version of NameMapper installed! "

from Cheetah.Template import Template
t = Template(file='home.tmpl')
print t

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\wamp\bin\Python27\lib\site-packages\Cheetah\Template.py", line 1005,
in __str__
    rc = getattr(self, mainMethName)()
  File "_wamp_www_b121pyraw_b121pycheetah_home_tmpl.py", line 89, in respond
  File "C:\wamp\bin\Python27\lib\site-packages\Cheetah\NameMapper.py", line 246,
 in valueFromSearchList
    _raiseNotFoundException(key, searchList)
  File "C:\wamp\bin\Python27\lib\site-packages\Cheetah\NameMapper.py", line 167,
 in _raiseNotFoundException
    raise NotFound(excString)
Cheetah.NameMapper.NotFound: cannot find 'firstdivcontents'

我为Python2.7搜索了@namemapper.pyd,但没有找到。我只找到了2.6的文件。 我是否必须降级到Python2.6,或者是否有其他方法来安装它。

另外,如果我找到了python,如何安装namemapper.pyd来使用它?


Tags: ofinpybinlibpackageslinesite
3条回答

我制作了一个namemapper python文件的副本,解决了只需修改文件扩展名从_namemapper.pyd_namemapper.so的问题,它工作得很好。

我不能肯定这是一个正确的做法,但为我工作。

文件C:\Python27\Lib\site-packages\Cheetah\Compiler.py

注释以下以第1506行开头的行以消除错误。

#        if not NameMapper.C_VERSION:
#            if not sys.platform.startswith('java'):
#                warnings.warn(
#                    "\nYou 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."
#                    )

pyd文件是通过编译包附带的C文件创建的。这是在安装时完成的,如果你手头有一个C编译器的话。如果没有,在本例中,您将得到一个Python fall back。有些软件包将拒绝安装。

没有C编译器的Windows用户的解决方案是安装预编译的C二进制软件包。猎豹似乎没有:http://pypi.python.org/pypi/Cheetah/2.4.4

所以你需要安装一个C编译器。我听说明是个不错的选择。

不过,我认为这根本不是你的问题。您的实际错误似乎与此警告无关。

所以如果你把你失败的代码包括进去,那些比我更习惯猎豹的人可能会告诉你出了什么问题。

相关问题 更多 >