gpt4 book ai didi

python - 解决 "500: Internal Server Error, nbconvert failed: xelatex not found in PATH"

转载 作者:太空狗 更新时间:2023-10-30 00:53:01 25 4
gpt4 key购买 nike

每当我尝试将 Jupyter notebook 导出为 PDF 时,我都会在单独的窗口中收到以下错误:

500 : Internal Server ErrorThe 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 notebook 中)和 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.fmtI 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com