大家在用Jupyter Notebook
编写交互程序时,有时会想把当前的操作流程以及结果保存下来,Jupyter
提供了多种文件导出方式:
可以看到
Jupyter
支持将交互界面导出成html
、md
、PDF
等多种格式,而我个人比较喜欢的是pdf
格式。但是在点击
Download as -> PDF via LaTex(.pdf)
时,会发现弹出界面报错了,错误信息会告诉你,想要导出pdf
,需要安装Tex
组件,并且很贴心的把安装说明网址告诉你:
https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex
接下来就是安装这个组件了,打开网页,可以看到在ubuntu
环境中,其实是安装一个叫Tex Live
的组件,安装命令为:
apt-get install texlive-xetex
安装完成之后,再点击导出pdf,结果会发现仍然是报错,这次的错误信息很复杂,大至意思是少了什么字体文件。
nbconvert failed: PDF creating failed, captured latex output:
This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013/Debian)
restricted \write18 enabled.
entering extended mode
(/root/ml/study/notebook.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 2 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo))
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def)
kpathsea: Running mktextfm ecrm1095
/usr/share/texlive/texmf-dist/web2c/mktexnam: Could not map source abbreviation for ecrm1095.
/usr/share/texlive/texmf-dist/web2c/mktexnam: Need to update ?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input ecrm1095
This is METAFONT, Version 2.718281 (TeX Live 2013/Debian)
kpathsea: Running mktexmf ecrm1095
! I can't find file `ecrm1095'.
<*> ...ljfour; mag:=1; nonstopmode; input ecrm1095
Please type another input file name
! Emergency stop.
<*> ...ljfour; mag:=1; nonstopmode; input ecrm1095
Transcript written on mfput.log.
grep: ecrm1095.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input ecrm1095' failed to make ecrm1095.tfm.
kpathsea: Appending font creation commands to missfont.log.
! Font T1/cmr/m/n/10.95=ecrm1095 at 10.95pt not loadable: Metric (TFM) file or
installed font not found.
<to be read again>
relax
l.100 \fontencoding\encodingdefault\selectfont
?
! Emergency stop.
<to be read again>
relax
l.100 \fontencoding\encodingdefault\selectfont
No pages of output.
Transcript written on notebook.log.
再去google
吧,找到如下命令:
apt-get install texlive-fonts-recommended
apt-get install cm-super
尝试一下,仍然报错,再次google
,这次成功了,命令如下:
apt-get install texlive-full
看一看导出效果,感觉不是很好看,不过能用了
导出的pdf效果
网友评论