Jupyter notebook 将nbconvert升级到6.x+;时如何解决TemplateNotFound错误;?
当尝试使用我过去使用过的模板制作一个新的基于Jupyter的演示文稿时,我发现当Jupyter notebook 将nbconvert升级到6.x+;时如何解决TemplateNotFound错误;?,jupyter-notebook,jupyter,nbconvert,Jupyter Notebook,Jupyter,Nbconvert,当尝试使用我过去使用过的模板制作一个新的基于Jupyter的演示文稿时,我发现当nbconvert升级到6.0以上时,我得到一个与缺少的内置模板basic.tpl相关的错误。为此,请创建一个名为custom.tpl的模板文件: {% extends 'basic.tpl' %} 然后取下任何Jupyter笔记本并安装Jupyter nbconvert,然后运行nbconvert notebook.ipynb--to=slides--template=custom.tpl。您将得到如下异常: [
nbconvert
升级到6.0以上时,我得到一个与缺少的内置模板basic.tpl
相关的错误。为此,请创建一个名为custom.tpl
的模板文件:
{% extends 'basic.tpl' %}
然后取下任何Jupyter笔记本并安装Jupyter nbconvert,然后运行nbconvert notebook.ipynb--to=slides--template=custom.tpl
。您将得到如下异常:
[NbConvertApp] Converting notebook example.ipynb to slides
Traceback (most recent call last):
File "/tmp/tmp.niaMlxSIbz/venv/bin/jupyter-nbconvert", line 8, in <module>
sys.exit(main())
...
File "/tmp/tmp.niaMlxSIbz/custom.tpl", line 1, in top-level template code
{% extends 'basic.tpl' %}
jinja2.exceptions.TemplateNotFound: basic.tpl
[NbConvertApp]将notebook example.ipynb转换为幻灯片
回溯(最近一次呼叫最后一次):
文件“/tmp/tmp.niaMlxSIbz/venv/bin/jupyter nbconvert”,第8行,在
sys.exit(main())
...
顶级模板代码中的文件“/tmp/tmp.niaMlxSIbz/custom.tpl”,第1行
{%extends'basic.tpl%}
jinja2.exceptions.TemplateNotFound:basic.tpl
如果您pip安装'nbconvert<6.0'
,您会发现相同的命令成功
我想这与相关,但我相信.tpl
模板仍然是受支持的,甚至有一个列表,但我在任何地方都找不到关于如何使用新位置的引用更新模板的说明
有没有办法通过将引用更改为'basic.tpl'
来解决这个问题
固定到5.6.1“有效”,但nbconvert的5.6.1版不适用于Python 3.9,我需要访问笔记本中一些较新的Python功能。我不知道
.tpl
文件是否有直接向后兼容性,但是您可以将模板指令迁移到新的模板目录格式中
使用jupyter--path
查找用户(或系统)的jupyter配置路径。从那里,您可以将自定义模板添加到templates目录中
$ jupyter --paths (master) ✓
config:
/Users/txoof/.jupyter << user templates can be found here on my system
/Users/txoof/.local/share/virtualenvs/folderAudit-FJk3azd9/etc/jupyter << jupyter default templates can be found here
/usr/local/etc/jupyter
/etc/jupyter
$jupyter--路径(主路径)✓
配置:
/Users/txoof/.jupyter