ipynb导出PDF报错

2 阅读1分钟

前置条件

安装了如下依赖

  1. pandoc(pandoc.org/)
  2. miktex(miktex.org/download)
  3. pip install nbconvert

image.png

image.png 使用jupyter保存

image.png 使用命令行保存

jupyter nbconvert your_notebook.ipynb --to pdf

报错处理

如果遇见 nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output: Failed to run "xelatex notebook.tex -quiet" command: xelatex: security risk: running with elevated privileges miktex-dvipdfmx: security risk: running with elevated privileges等报错可以使用如下方式处理

先导出成html

jupyter nbconvert --to html your_notebook.ipynb

然后用浏览器打开,在打印成pdf就可以了