jupyter nbconvert pdf failed: xelatex not found error
Fixes `jupyter nbconvert pdf failed: xelatex not found`: the TeX distribution is missing or not on PATH. Install TeX Live (or equivalent) and confirm `xelatex` resolves. Not for LaTeX compile errors.
TL;DR
nbconvert shells out to xelatex for PDF export, and xelatex not found means there is no TeX distribution installed or its binaries are not on the PATH of the environment running nbconvert. Install a full TeX distribution (TeX Live on Linux, MacTeX on macOS, MiKTeX on Windows), open a new shell, and confirm which xelatex prints a path. Then re-run the PDF export.
jupyter nbconvert pdf failed: xelatex not found errorUse this when
- PDF export fails immediately with
xelatex not found. - HTML export works but PDF does not.
- The machine is a fresh container or CI runner.
Not for this skill when
- xelatex runs but the compile fails. That is a LaTeX error, not a missing binary.
- You want PDF without TeX. Use the webpdf exporter instead.
Steps
- Check for any TeX:
which xelatex pdflatex latex. Verify: all empty, confirming nothing is installed. - Install a TeX distribution:
apt-get install texlive-xetexon Debian/Ubuntu (or the fulltexlivescheme for regular use). Verify: the install completes. - Open a new shell and run
which xelatex. Verify: it prints a binary path. - Re-run
jupyter nbconvert --to pdf nb.ipynb. Verify: the PDF is produced. - If nbconvert runs in a different env (container, CI), install TeX there, not on your laptop. Verify:
xelatexresolves inside that environment.
Variant phrasings
xelatex not found nbconvert
Short form. Install a TeX distribution.
nbconvert pdf no latex installed
The cause phrasing. Same install.
jupyter pdf export missing xelatex
UI phrasing. PATH or install.
Compatibility: nbconvert 6/7. The xelatex dependency is unchanged across versions.
Why it happens
PDF-via-LaTeX is a two-stage pipeline: nbconvert renders .tex, then xelatex compiles it. The first stage needs only python; the second needs a multi-gigabyte TeX distribution that minimal containers and fresh machines never have. nbconvert does not bundle TeX, so the failure is environmental, and installing the distribution is the entire fix.
Edge cases / pitfalls
- The minimal
texlive-xetexpackage lacks many LaTeX packages notebooks use. Install the full scheme if compiles then fail on missing packages. - Installing TeX on your laptop does not help a CI job. Match the install to the execution environment.
- TeX installs are huge (gigabytes). In containers, consider the webpdf exporter to avoid the weight.
- After installing, nbconvert processes started before the install may still have the old PATH. Restart them.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstSWpRw6APK9z_tpLTceDjg