Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solving "500: Internal Server Error, nbconvert failed: xelatex not found in PATH"

Whenever I try to export a Jupyter notebook as a PDF I get the following error in a separate window:

500 : Internal Server Error The error was:  nbconvert failed: xelatex not found on PATH, if you have not installed xelatex you may need to do so. Find further instructions at https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex. 

I am running macOS Sierra 10.12.6.

Things I have tried:

  • Re-installing nbconvert through pip (in the Jupyter notebook) and conda (terminal)
  • Installing xelatex for Mac
  • Re-installing Mactex
  • Installing pandoc (both through pip and through "conda install -c conda-forge pandoc")

Running

!echo $PATH 

Yields:

/Users/ed/anaconda/bin:/Users/ed/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin 

I located the directory containing xelatex as per @einsweniger suggestion here: /usr/local/texlive/bin/x86_64-darwin. I copied and pasted XeLatex into the bin directory above, and get a new error:

```nbconvert failed: PDF creating failed, captured latex output: warning: kpathsea: configuration file texmf.cnf not found in these directories: /Users/e/anaconda/bin:/Users/ed/anaconda/bin/share/texmf-local/web2c:/Users/ed/anaconda/bin/share/texmf-dist/web2c:/Users/ed/anaconda/bin/share/texmf/web2c:/Users/ed/anaconda/bin/texmf-local/web2c:/Users/ed/anaconda/bin/texmf-dist/web2c:/Users/ed/anaconda/bin/texmf/web2c:/Users/ed/anaconda:/Users/edefilippis/anaconda/share/texmf-local/web2c:/Users/e/anaconda/share/texmf-dist/web2c:/Users/ed/anaconda/share/texmf/web2c:/Users/ed/anaconda/texmf- This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018) (preloaded format=xelatex)  kpathsea: Running mktexfmt xelatex.fmt I can't find the format file `xelatex.fmt'! ``` 

I also put xelatex.fmt in the directory, but am still getting the error.

like image 740
Parseltongue Avatar asked Sep 12 '18 17:09

Parseltongue


1 Answers

I encountered the same issue. As people previously stated, the problem lies in that xlatex isn't found in your PATH environment variable.

A solution that worked for me was to run the following from the notebook:

!export PATH=/Library/TeX/texbin:$PATH 

Or in a command line simply:

export PATH=/Library/TeX/texbin:$PATH 

And then run the export to pdf from a command line (within your virtual environment if there is one in place) as follows:

 jupyter nbconvert your_notebook.ipynb --to pdf 

This should create a pdf of your notebook on the same directory it is running.

like image 90
Nico Avatar answered Oct 11 '22 02:10

Nico