1

I'm facing the same problem as PyLaTeX: pylatex.errors.CompilerError: No LaTex compiler was found but I have not found an answer yet. I´m using Windows and I have the MixTex and pylatex packages installed.

I'm trying first this to then added to other code but is not runnig.

from pylatex import Document, Section, Subsection
from pylatex.utils import italic
import pdflatex

def document(doc):
    geometry_options = {"tmargin": "1cm", "lmargin": "10cm"}
    doc =Document(geometry_options=geometry_options)
    
    with doc.create(Section('Results')):
         doc.append('Something')
    doc.generate_pdf('Results', clean_tex=False, compiler='pdfLaTeX')
    tex = doc.dumps() 

I would like to get some help here. The error is the same:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "generalcode.py", in validation
    doc.generate_pdf('Resultados', clean_tex=False, compiler='pdfLaTeX')
  File "C:Python\Python38-32\lib\site-packages\pylatex\document.py", in generate_pdf
    raise(CompilerError(
pylatex.errors.CompilerError: No LaTex compiler was found
Either specify a LaTex compiler or make sure you have latexmk or pdfLaTex installed.
Richard21
  • 157
  • 1
  • 9
  • Are you sure you have latex installed? Open a command prompt and type `pdflatex --version`. What output do you get? – Pranav Hosangadi Oct 08 '20 at 18:51
  • I have the last version `pdflatex==0.1.3` in python and I installed MixTex after install `pylatex` packages in python so I think it should be running but is not. – Richard21 Oct 08 '20 at 18:57
  • 2
    Open a command prompt and type `pdflatex --version`. What output do you get? If `pdflatex` is not accessible on the path, python could think that you don't have it installed. If this is the case, add the directory of your `pdflatex` executable to the path and restart python – Pranav Hosangadi Oct 08 '20 at 18:59
  • I use pip freeze to check it but using what you comment I get `bash: pdflatex: command not found`. – Richard21 Oct 08 '20 at 19:06
  • I solved. I had to restart python. I had not close the command prompt after the installation of `MixTex` and that was why I was having that issue. As @PranavHosangadi said , when you put `pdflatex --version`. it have to show the path of the pdflatex, if not maybe you have not restarted python yet after installing Latex. – Richard21 Oct 08 '20 at 19:25

0 Answers0