Conner Leverett
Conner Leverett

Reputation: 593

PyLatex basic script won't run because script interpreter could not be found

I'm trying to learn PyLatex. I've installed it via pip and copied the basic code from here and I'm getting this issue:

C:\Conner\Scripts>pylatAttempt.py
latexmk: The script interpreter could not be found.
latexmk: Data: scriptInterpreter="perl.exe"
Traceback (most recent call last):
File "C:\Conner\Scripts\pylatAttempt.py", line 23, in <module>doc.generate_pdf()
File "C:\Python27\ArcGIS10.2\lib\site-packages\pylatex\document.py", line 193, in generate_pdf raise(e) 
subprocess.CalledProcessError: Command '[u'latexmk', u'--pdf', u'--interaction=nonstopmode', u'basic.tex']' returned non-zero exit status 1

I've downloaded MiKTeX 2.9, do I need anything else? What is going wrong here? From the docs it seems like all you need to install is pylatex.

Upvotes: 8

Views: 11033

Answers (3)

Rohan Nayak
Rohan Nayak

Reputation: 121

You can change the compiler to pdflatex instead of latexmk which will work if you have installed miktex and pdflatex . latexmk is compiler by default.

doc.generate_pdf(clean_tex=False,compiler='pdfLaTeX')

Upvotes: 12

hygull
hygull

Reputation: 8740

I am using Python 2.7.14 :: Anaconda, Inc. and I faced the same issue when I first tried to execute the PyLaTeX's example available at https://jeltef.github.io/PyLaTeX/latest/examples/basic.html.

1) When I executed the copied code before installation of MikTeX

  (pylatex) G:\RishikeshAgrawani\ProjectsWin7\Python3\PyLaTeX\pylatex\01_basic>python 01
  Traceback (most recent call last):
    File "01_basic.py", line 24, in <module>
      doc.generate_pdf(clean_tex=False)
    File "C:\Anaconda2.5.0.1\lib\site-packages\pylatex\document.py", line 317, in genera
      u'or make sure you have latexmk or pdfLaTex installed.'
  pylatex.errors.CompilerError: No LaTex compiler was found
  Either specify a LaTex compiler or make sure you have latexmk or pdfLaTex installed.

2) After installation of MikTeX

You can see above output, it is looking for LaTex compiler that we can install by installing MikTeX.

Also read Using latexmk with MikTeX.

You can download MikTeX at https://miktex.org/download.

  (C:\Anaconda2.5.0.1) G:\RishikeshAgrawani\ProjectsWin7\Python3\PyLaTeX\pylatex\01_basic>python 01_basic.py
  latexmk: The script engine could not be found.
  latexmk: Data: scriptEngine="perl.exe"

  Traceback (most recent call last):
    File "01_basic.py", line 24, in <module>
      doc.generate_pdf(clean_tex=False)
    File "C:\Anaconda2.5.0.1\lib\site-packages\pylatex\document.py", line 269, in generate_pdf
      stderr=subprocess.STDOUT)
    File "C:\Anaconda2.5.0.1\lib\subprocess.py", line 219, in check_output
      raise CalledProcessError(retcode, cmd, output=output)
  subprocess.CalledProcessError: Command '[u'latexmk', u'--pdf', u'--interaction=nonstopmode', u'basic.tex']' returned non-zero exit
   status 1

3) After installation of STARWBERRY PERL

You can see above ouptput, it is looking for perl.exe.

So I downloaded Strawberry perl from http://strawberryperl.com/ and installed it.

Now I successfully ran the code and got the PDF.

  (C:\Anaconda2.5.0.1) G:\RishikeshAgrawani\ProjectsWin7\Python3\PyLaTeX\pylatex\01_basic>python 01_basic.py

  (C:\Anaconda2.5.0.1) G:\RishikeshAgrawani\ProjectsWin7\Python3\PyLaTeX\pylatex\01_basic>

That's it.

Upvotes: 5

Conner Leverett
Conner Leverett

Reputation: 593

If anyone stumbles upon this it turns out that for PyLatex to work you also have to have Perl installed. Once I downloaded Perl from here it worked. Make sure Perl is in the PATH.

Upvotes: 5

Related Questions