每当我尝试将Jupyter笔记本导出为PDF时,都会在单独的窗口中出现以下错误:
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.
我正在运行macOS Sierra 10.12.6。
我尝试过的事情:
运行
!echo $PATH
产量:
/Users/ed/anaconda/bin:/Users/ed/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin
我按照@einsweniger建议在这里找到了包含xelatex的目录:/usr/local/texlive/bin/x86_64-darwin。我将XeLatex复制并粘贴到上面的bin目录中,并得到一个新错误:
```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'!
```
我也将xelatex.fmt放在目录中,但是仍然出现错误。
最佳答案
我遇到了同样的问题。正如人们先前所说,问题在于您的PATH环境变量中找不到xlatex。
一个对我有用的解决方案是从笔记本计算机运行以下命令:
!export PATH=/Library/TeX/texbin:$PATH
或仅在命令行中:
export PATH=/Library/TeX/texbin:$PATH
然后从命令行运行导出到pdf(在虚拟环境中,如果有的话),如下所示:
jupyter nbconvert your_notebook.ipynb --to pdf
这应该在笔记本计算机运行的同一目录下创建一个pdf文件。
关于python - 解决 “500: Internal Server Error, nbconvert failed: xelatex not found in PATH”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52300242/