Command '['latexmk', '--pdf', '--interaction=nonstopmode', 'XXX']' returned non-zero exit status 12

1.6k Views Asked by At

I wanted to use pylatex and tried to generate the example file. I have installed the packages with anaconda (pylatex and latexmk with conda-forge) and having following code:

from pylatex import Document, PageStyle, Head, MiniPage, Foot, LargeText, \
    MediumText, LineBreak, simple_page_number
from pylatex.utils import bold


def generate_header():
    geometry_options = {"margin": "0.7in"}
    doc = Document(geometry_options=geometry_options)
    # Add document header
    header = PageStyle("header")
    # Create left header
    with header.create(Head("L")):
        header.append("Page date: ")
        header.append(LineBreak())
        header.append("R3")
    # Create center header
    with header.create(Head("C")):
        header.append("Company")
    # Create right header
    with header.create(Head("R")):
        header.append(simple_page_number())
    # Create left footer
    with header.create(Foot("L")):
        header.append("Left Footer")
    # Create center footer
    with header.create(Foot("C")):
        header.append("Center Footer")
    # Create right footer
    with header.create(Foot("R")):
        header.append("Right Footer")

    doc.preamble.append(header)
    doc.change_document_style("header")

    # Add Heading
    with doc.create(MiniPage(align='c')):
        doc.append(LargeText(bold("Title")))
        doc.append(LineBreak())
        doc.append(MediumText(bold("As at:")))

    doc.generate_pdf("header", clean_tex=False)

generate_header()

I am getting this error:

Traceback (most recent call last):
  File "/Users/user/git/project/test.py", line 43, in <module>
    generate_header()
  File "/Users/user/git/project/test.py", line 41, in generate_header
    doc.generate_pdf("header", clean_tex=False)
  File "/Users/user/opt/anaconda3/envs/env/lib/python3.11/site-packages/pylatex/document.py", line 250, in generate_pdf
    output = subprocess.check_output(command,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/opt/anaconda3/envs/env/lib/python3.11/subprocess.py", line 465, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/opt/anaconda3/envs/env/lib/python3.11/subprocess.py", line 569, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['latexmk', '--pdf', '--interaction=nonstopmode', 'XXX']' returned non-zero exit status 12.

Additionally before the Traceback it says: sh: pdflatex: command not found although I have installed it in the anaconda environment.

The XXX location is pointing to the right anaconda environment so I have no idea what's wrong here.

0

There are 0 best solutions below