在Windows中使用Mako
我打算在Windows上使用wsgi和mako。
我通过以下方式安装了mako:
C:\wsgi>c:\Python26\Scripts\easy_install.exe Mako
没有错误。我在消息的最后得到了:
Finished processing dependencies for Mako
我检查了我的Python目录,发现有以下结构:
C:\Python26\Lib\site-packages\mako-0.2.5-py2.6.egg
C:\Python26\Lib\site-packages\mako-0.2.5-py2.6.egg\EGG-INFO
C:\Python26\Lib\site-packages\mako-0.2.5-py2.6.egg\mako
C:\Python26\Lib\site-packages\mako-0.2.5-py2.6.egg\mako\ext
我运行了以下代码 HelloWorld.py:
from mako.template import Template
def application(environ, start_response):
status = '200 OK'
mytemplate = Template("hello, ${name}!")
output = mytemplate.render(name="jack")
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
我得到了以下错误日志:
[Fri Feb 05 16:11:19 2010] [error] [client 127.0.0.1] File "C:/wsgi/HelloWorld.py", line 1, in <module>
[Fri Feb 05 16:11:19 2010] [error] [client 127.0.0.1] from mako.template import Template
[Fri Feb 05 16:11:19 2010] [error] [client 127.0.0.1] ImportError: No module named mako.template
有什么建议吗?
1 个回答
1
这里有几个建议可以试试:
- 确保你使用的是 Python 2.6 版本。
- 试着运行
import mako
,看看是否会出现类似的错误。 - 如果 mako 能正常导入,查看
repr(mako)
的值,确保它与你的路径相符。