title: Solving "500: Internal Server Error, nbconvert failed: xelatex not found in PATH"
body: <p>Whenever I try to export a Jupyter notebook as a PDF I get the following error in a separate window:</p>
  
  <pre><code>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.
  </code></pre>
  
  <p>I am running macOS Sierra 10.12.6.</p>
  
  <p>Things I have tried:</p>
  
  <ul>
  <li>Re-installing nbconvert through pip (in the Jupyter notebook) and conda (terminal)</li>
  <li>Installing xelatex for Mac</li>
  <li>Re-installing Mactex</li>
  <li>Installing pandoc (both through pip and through "conda install -c conda-forge pandoc")</li>
  </ul>
  
  <p>Running</p>
  
  <pre><code>!echo $PATH
  </code></pre>
  
  <p>Yields:</p>
  
  <pre><code>/Users/ed/anaconda/bin:/Users/ed/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>```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'!
  ```
  </code></pre>
  
  <p>I also put xelatex.fmt in the directory, but am still getting the error. </p>