2011-01-19 184 views
4

我的Windows 2.7系統上安裝了Python 2.7與Cheetah。下面是我得到的錯誤,當我嘗試使用.tmpl文件中的cheetah.template對象。我在哪裏可以得到以及如何在Windows上爲Python 2.7安裝_namemapper.pyd

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' 

我搜索了python 2.7的_namemapper.pyd,但我沒有得到。我發現只有2.6以上的文件。 我必須降級到Python 2.6,還是有其他方法來安裝它。

以及如何安裝_namemapper.pyd與蟒蛇的工作,如果在所有我找到它?

回答

3

的PYD文件由編譯附帶套餐的C文件創建的。這是在安裝時完成的,如果你有一個方便的C編譯器。如果沒有,你在這種情況下會得到一個Python回落。有些軟件包會拒絕安裝。

沒有C編譯器的Windows人的解決辦法是安裝預編譯的C二進制軟件包。獵豹似乎沒有任何的:http://pypi.python.org/pypi/Cheetah/2.4.4

所以,你需要安裝一個C編譯器。我聽說MinGW是一個不錯的選擇。

不過,我不認爲那是你的問題的。您的實際錯誤似乎與此警告無關。

所以,如果你有你的失敗代碼,人們更習慣於獵豹比我大概可以告訴你,什麼是錯的。

-1

文件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." 
#     ) 
+2

這只是一個警告,將使用非C版本的namemapper。在我看來,註釋掉這個警告是相當愚蠢的建議 - 你可以簡單地忽略這個警告,使用python版本的namemapper會使性能變差。所以降低了這個答案。 – DEzra 2013-04-15 18:15:59

-1

我做namemapper蟒蛇文件的副本,我解決我的問題只是讓從_namemapper.pyd_namemapper.so文件擴展名的修改和它的工作就好了。

我不能肯定這是一個正確的做法,但爲我工作。

相關問題