1

如果在其他地方发布了类似的问题,我们深表歉意。我正在尝试切换到 Python 来排版新项目,但发现设置非常困难。为此,我遇到了 PyLatex,它看起来很有希望我已经通过 pip 遵循了设置说明,安装了 LatexMK,并尝试执行基本示例文件来测试它。这失败了,向我抛出以下错误:

runfile('/Users/~/.spyder-py3/untitled0.py', wdir='/Users/~/.spyder-py3')
Latexmk: This is Latexmk, John Collins, 17 Jan. 2018, version: 4.55.
Rule 'pdflatex': File changes, etc:
   Non-existent destination files:
      'basic.pdf'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex  --interaction=nonstopmode -recorder  "basic.tex"'
------------
Latexmk: applying rule 'pdflatex'...
sh: pdflatex: command not found
Collected error summary (may duplicate other messages):
  pdflatex: (Pdf)LaTeX failed to generate the expected log file 'basic.log'
Latexmk: Did not finish processing file 'basic.tex':
   (Pdf)LaTeX failed to generate the expected log file 'basic.log'
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs of latex/pdflatex.
Latexmk: Errors, so I did not complete making targets

Traceback (most recent call last):

  File "<ipython-input-24-35bb0f8240b1>", line 1, in <module>
    runfile('/Users/~/.spyder-py3/untitled0.py', wdir='/Users/~/.spyder-py3')

  File "/Users/~/opt/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "/Users/~/opt/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "/Users/~/.spyder-py3/untitled0.py", line 32, in <module>
    doc.generate_pdf(clean_tex=False)

  File "/Users/~/opt/anaconda3/lib/python3.7/site-packages/pylatex/document.py", line 233, in generate_pdf
    stderr=subprocess.STDOUT)

  File "/Users/~/opt/anaconda3/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout

  File "/Users/~/opt/anaconda3/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)

CalledProcessError: Command '['latexmk', '--pdf', '--interaction=nonstopmode', 'basic.tex']' returned non-zero exit status 12.

我在 Mac (OS 10.15.4) 上使用带有 Python 3.7 的 Anaconda 环境。我希望实现的是创建一个 Latex 文件并生成一个 pdf,就像我通常使用 Latex 一样。

谢谢你的帮助!

4

0 回答 0