Gevent - ImportError: No module named mako_templating

Gevent - ImportError: No module named mako_templating

我正在关注 2012 年的视频 - Gevent-socketio,跨框架实时网络现场演示 (https://www.youtube.com/watch?v=zhh_N5pmHBY)

我正在 Ubuntu 15.04.

在 8 分钟时,在 init.py 中他纠正了 config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory') 但之后我仍然无法让它工作。我得到的错误如下。

我们将不胜感激任何帮助。

谢谢

(env)cloud@cloudnetwork:~/Code/python/3/moo/Moo$ pserve --reload development.ini
Starting subprocess with file monitor
Traceback (most recent call last):
 File "/home/cloud/Code/python/3/moo/env/bin/pserve", line 9, in <module>
   load_entry_point('pyramid==1.5.7', 'console_scripts', 'pserve')()
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 58, in main
   return command.run()
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 328, in run
   global_conf=vars)
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 363, in loadapp
   return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
   return loadobj(APP, uri, name=name, **kw)
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
   return context.create()
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
   return self.object_type.invoke(self)
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
   return fix_call(context.object, context.global_conf, **context.local_conf)
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
   val = callable(*args, **kw)
 File "/home/cloud/Code/python/3/moo/Moo/moo/__init__.py", line 10, in main
   config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory')
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/util.py", line 528, in wrapper
   result = wrapped(self, *arg, **kw)
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/config/rendering.py", line 33, in add_renderer
   factory = self.maybe_dotted(factory)
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 825, in maybe_dotted
   return self.name_resolver.maybe_resolve(dotted)
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/path.py", line 320, in maybe_resolve
   return self._resolve(dotted, package)
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/path.py", line 327, in _resolve
   return self._zope_dottedname_style(dotted, package)
 File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/path.py", line 382, in _zope_dottedname_style
   __import__(used)
ImportError: No module named mako_templating

根据您安装金字塔的方式,您还需要安装 pyramid_mako,例如 运行 pip install pyramid_mako。它是一个单独的模块,不是金字塔本身的一部分。

在 Pyramid 中注册要作为 Mako 模板处理的新扩展的最简单方法如下:

config.include('pyramid_mako')
config.add_mako_renderer('.html')

这将正确设置渲染器。


Mako 模板已从 Pyramid 核心框架中删除,因此 pyramid.mako_templating.* 不再存在。