我尝试在安装了texlive-*
的 Arch Linux 上运行以下 Python 代码:
from latex import build_pdf
# Read the template from the file...
min_latex = (r"documentclass{article}"
r"begin{document}"
r"Hello, world!"
r"end{document}")
# Compile it...
pdf = build_pdf(min_latex)
# Save the generated .pdf to a new file...
path_to_save = 'new_file.pdf'
pdf.save_to(path_to_save)
它返回异常:latex.exc.LatexBuildError: None
而且我既不能构建任何乳胶文件,也不能构建字符串,也不能使用任何构建器。 我尝试使用LatexMkBuilder()
(从 AUR 安装latex-mk
后(并手动PdfLatexBuilder
.build_pdf()
,但没有结果。
但是,它之前(大约一个月前(有效。IDK到底发生了什么。 有什么建议吗?
更新1:它开始下降subprocess.check_call()
build_pdf()
。
更新2:似乎在latex
,创建临时文件是一个问题,这会导致FileNotFoundError
subprocess.check_call()
。
在PowerShell中运行脚本时,我遇到了同样的错误(但由于某种原因,没有在git-bash中(。我发现将构建器从latexmk
更改为pdflatex
有所帮助;即,在这个例子中,让我们:
pdf = build_pdf(min_latex, builder='pdflatex')