本文介绍了解决&Quot;500:内部服务器错误,nbConvert失败:在路径&Quot;中找不到xelatex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试将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。

我已尝试的内容:

  • 通过pip(在Jupyter笔记本中)和conda(终端)重新安装nbConvert
  • 安装用于Mac的Xelatex
  • 重新安装Mactex
  • 安装Pandoc(通过pip和"conda install-c conda-forge pandoc")

正在运行

!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。

这篇关于解决&Quot;500:内部服务器错误,nbConvert失败:在路径&Quot;中找不到xelatex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 12:59