nbconvert to html failed with 'template not found' jinja error
Fixes nbconvert HTML export failing with a jinja 'template not found' error: the template name is wrong, nbconvert is old, or a custom template path is misconfigured. Check the template name and version. Not for LaTeX errors.
TL;DR
The jinja template loader cannot find the template nbconvert asked for, which means the template name is misspelled, the nbconvert version does not ship that template, or a custom --template-path points nowhere. List available templates with jupyter nbconvert --to html --template=[name] variants or check the docs for your version, use --template lab or classic explicitly, and verify the named template exists before scripting the export.
nbconvert to html failed with 'template not found' jinja errorUse this when
- HTML export fails with jinja2 TemplateNotFound.
- You passed a custom
--templatename. - nbconvert was recently upgraded or downgraded.
Not for this skill when
- HTML exports but looks broken. That is a template content issue.
- The failure is a LaTeX error. That is the PDF path.
Steps
- Confirm the nbconvert version:
jupyter nbconvert --version. Verify: you know which templates it ships. - Try the stock templates explicitly:
--template labthen--template classic. Verify: one of them works, proving the loader is fine. - If you need a custom template, check the path:
--template-pathmust contain a directory with the template files. Verify: the files exist at that path. - Fix the template name spelling against the actual directory name. Verify: the name matches exactly, case included.
- Re-run the export. Verify: the HTML file is written without jinja errors.
Variant phrasings
nbconvert template not found
Short form. Name or path is wrong.
jinja template not found nbconvert html
Library phrasing. Check the template loader inputs.
nbconvert html export template error
General phrasing. Try stock templates first.
Compatibility: nbconvert 6/7. Template names changed across versions (e.g. basic to lab); check your version's docs.
Why it happens
nbconvert 6+ reorganized its template system around named template directories, and names that existed in nbconvert 5 (or in blog posts) do not exist in 6/7. Jinja's loader then raises TemplateNotFound, which nbconvert passes through with little context. Custom template paths add the second failure mode: a relative path that resolves differently when the export runs from another directory.
Edge cases / pitfalls
- Copying a
--templateinvocation from an old tutorial is the most common trigger. Check the name against your installed version. - Template directories need specific files (conf.json, index.html.j2). A half-copied custom template fails the same way.
- User-level template dirs (
share/jupyter/nbconvert/templates) can shadow stock names. Check for shadowing if stock names fail. - The error message names the missing template; read it literally instead of guessing.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstOqxhutVEPo-8ZcZ1R9AXA