NotImplementedError:无法针对未注册的加载器类型执行此操作 [英] NotImplementedError: Can't perform this operation for unregistered loader type
问题描述
我正在制作一个小的脚本来生成HTML文件.为此,我正在使用jinja2
.
I'm making a small script to generate an HTML file. For this purpose, I'm using jinja2
.
这是我的脚本(在jinja2
文档中找到):
This is my script (found in the jinja2
documentation):
# -*- coding: utf-8 -*-
from jinja2 import Environment, PackageLoader
env = Environment(loader = PackageLoader('monapplication', 'templates'))
template = env.get_template('index.html')
print(template.render(message = "Bienvenue sur mon site !"))
"monapplication"软件包包含index.html文件所在的文件夹"templates".
The package "monapplication" contains the folder "templates" where my index.html file is located.
但是当我运行脚本时,出现此错误:
But when I run the script, I get this error:
"NotImplementedError;无法对未注册的用户执行此操作 加载程序类型."
"NotImplementedError; Can't perform this operation for unregistered loader type."
我做了一些研究,但没有找到解决我问题的方法.
I did some research, but I didn't find any solution for my problem.
我的操作系统是Windows 10.
My OS is Windows 10.
推荐答案
我遇到了同样的问题.问题在于"monaaplication"被称为目录,而不是python软件包.
I had the same issue. The problem was that 'monaaplication' was known as a directory and not a python package.
尝试将 __ init __.py 文件添加到目录"monaaplication". (这就是告诉Python将这个目录视为一个包的原因.)
Try to add an __init__.py file to the directory 'monaaplication'. (This is what tells Python to treat this directory as a package.)
这篇关于NotImplementedError:无法针对未注册的加载器类型执行此操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!