0

I am trying to run this line of code to generate a report using pylatex:

doc.generate_pdf(report_name, clean_tex=True)

This works well to generate a pdf file without any error when I use Spyder and Jupyter Notebook to execute the program, but when I try to use Crontab to automate my task by executing the exact same py file every day,

0 6 * * * cd /Users/me/my_folder && /anaconda3/bin/python3 MyProgram.py

the following error occurs via terminal mail:

Traceback (most recent call last):
File "MyProgram.py", line 255
doc.generate_pdf(report_name, clean_tex=True)
File "/anaconda3/lib/python3.7/site-packages/pylatex/document.py", line 299, in generate_pdf
'No LaTex compiler was found\n'
pylatex.errors.CompilerError: No LaTex compiler was found
Either specify a LaTex compiler or make sure you have latexmk or pdfLaTex installed.

I have spent hours searching for solutions online but still cannot fix the bug. So I would like to get some help. Thanks in advance.

  • 1
    What is the location of your compiler? Cron uses different PATH, e.g. doesn't have /usr/bin in there. You can either pass the full location to the call ("Either specify a LaTex compiler") or change the location of your compiler to e.g. /bin (which is in cron's PATH) or add a local link... or change what PATH cron uses - https://stackoverflow.com/a/2409369/11516012 – h4z3 Sep 06 '21 at 09:22
  • The problem has been solved by passing the full location to the call. Thanks a lot. doc.generate_pdf(report_name, clean_tex=True, compiler="/Library/TeX/texbin/pdflatex") – NetAndChill Sep 06 '21 at 11:47

0 Answers0