jinja2: Can't perform this operation for unregistered loader type

代码:

# -*- coding: utf-8 -*-

from jinja2 import Environment, PackageLoader

env = Environment(loader = PackageLoader('app', 'templates'))
template = env.get_template('index.html')
print(template.render(message = "Bienvenue sur mon site !"))

运行后报错

NotImplementedError: Can't perform this operation for unregistered loader type

解决
添加文件 __init__.pyapp文件夹下

参考
NotImplementedError: Can’t perform this operation for unregistered loader type

你可能感兴趣的:(python)