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

简介: 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

相关文章
|
3月前
ESLint—— Failed to load config "standard" to extend from
ESLint—— Failed to load config "standard" to extend from
74 0
‘;‘ expected,Missing semicolon.Syntax Missing semicolon multi (web,若依定义方法,修改method,之后在mounted()用this
‘;‘ expected,Missing semicolon.Syntax Missing semicolon multi (web,若依定义方法,修改method,之后在mounted()用this
|
4月前
|
JavaScript 前端开发
We‘re sorry but xxxxxx doesn‘t work properly without JavaScript enabled.
We‘re sorry but xxxxxx doesn‘t work properly without JavaScript enabled.
|
6月前
|
JavaScript 程序员 Swift
The compiler is unable to type-check this expression in reasonable time; try breaking up the express
The compiler is unable to type-check this expression in reasonable time; try breaking up the express
71 0
|
6月前
|
JavaScript 前端开发
ESLint—— Failed to load config “standard“ to extend from
ESLint—— Failed to load config “standard“ to extend from
178 0
|
6月前
|
JavaScript
解决报错did you register the component correctly? For recursive components, make sure to provide the “na
解决报错did you register the component correctly? For recursive components, make sure to provide the “na
|
虚拟化
成功解决Failed to execute stage ‘Setup validation’: Hardware does not support virtualization.
成功解决Failed to execute stage ‘Setup validation’: Hardware does not support virtualization.
|
11月前
Error: Plugin/Preset files are not allowed to export objects, only functions……
Error: Plugin/Preset files are not allowed to export objects, only functions……
成功解决Failed to execute stage ‘Setup validation’: Cannot locate gluster packages
成功解决Failed to execute stage ‘Setup validation’: Cannot locate gluster packages
Fullpage.js version 3 has changed its license to GPLv3 and it requires a `licenseKey` option ...
Fullpage.js version 3 has changed its license to GPLv3 and it requires a `licenseKey` option ...
144 0