用jupyter notebook导出pdf时,因为报错信息,需要用到Tex
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.
目录
一 LaTex安装
1. macOS版
1.1 Tex Live下载 安装
1.2 TeXstudio编辑器下载安装
2. windows版
2.1 TexLive下载安装
直接git下载
git clone https://github.com/latex3/latex2e.git
或者
双击.bat文件
大概需要1-2小时,如果安装失败,重新进行安装
查看是否安装成功:
latex -v
2.2 TeXstudio编辑器的安装
下载后,双击安装,安装路径选择默认最好!!!
3.安装验证
安装完成后,打开编辑器
搜索栏搜索“TeXstudio”(为了方便,快捷方式可以移到桌面)
1、新建一个空白文件
2. 编写一个简单的文档,编译并查看效果
\documentclass[UTF8]{article}
\begin{document}
hello!
\end{document}
输入代码后,构建并查看
macOS
3、保存
最后,请记住自己安装texlive和texstudio的路径!!!!
我的路径:
C:/softwares/texlive/2024
C:\Program Files\texstudio
4.导出验证
重启jupyter notebook,再次导出pdf,成功!!!!!
pdf如下:
如果还不行的话,尝试配置路径,把C:\softwares\texlive\2024\bin\windows路径加入path中
5.不显示中文处理
由上图可看出红色箭头指向的 # 号后面的中文没有显示出来
修改jupyter内置文件(以下是路径)
macOS下的路径:
/Users/mac/Library/Python/3.9/share/jupyter/nbconvert/templates/latex
修改的代码如下:
\documentclass[11pt]{ctexart}
修改前:
修改后:
重启jupyter notebook后,导出,中文显示了
二 如果上面的不行,再用下面的方法
1安装Pandoc
Pandoc官网下载地址: https://pandoc.org/installing.html
git下载
Release pandoc 3.1.6.2 · jgm/pandoc · GitHub
正常安装即可
gitcode的镜像也有:https://gitcode.net/mirrors/jgm/pandoc/-/releases/3.1.6.1?spm=1033.2243.3001.5876
2安装MiKTex
如果导出pdf通过LaTex,还需要下载MiKTex: https://miktex.org/download
正常安装即可!
记得重启jupyter notebook!!!!!