Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
When trying to make a new Jupyter-based presentation using a template I've used in the past, I found that when
nbconvert
is upgraded past 6.0, I get an error related to a missing built-in template
basic.tpl
. A minimal reproducer for this, create a template file called
custom.tpl
:
{% extends 'basic.tpl' %}
Then take any Jupyter notebook and pip install jupyter nbconvert
and run nbconvert notebook.ipynb --to=slides --template=custom.tpl
. You'll get an exception like this:
[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
If you pip install 'nbconvert < 6.0'
, you'll find that the same command succeeds.
I imagine this is related to the changes to how templates work that came in 6.0, but I believe that .tpl
templates are still intended to be supported, and there is even a listed PR that restores the basic template, but I can find no instructions anywhere on how to update my template with references to the new location.
Is there some way to fix this by changing the reference to 'basic.tpl'
?
Pinning to 5.6.1 "works", but version 5.6.1 of nbconvert
doesn't work with Python 3.9, and I need access to some of the newer Python features in my notebook.
I don't know if there's a direct backwards compatibility for .tpl
files, but you can migrate your template directives into a the new template directory format.
Use jupyter --paths
to find your user (or system) jupyter config paths. From there, you can add custom templates into the templates directory.
$ 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
I had success by copying one of the default system templates into my user template directory and pasting my directives from my .tpl files into the index.py.j2
file.
You can find more details for migrating from nbconvert 5 to 6 here.
The documentation for moving from 5 to 6 is pretty awful as of November of 2020, but the nbconvert issues at github are pretty active and helpful.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.