1

I'm trying to create a pdf file inside a python/django project. I'm using PyLatex, which helps, but it's generate_pdf method breaks when it calls pdflatex. I keep getting this error:

FileNotFoundError: [Errno 2] No such file or directory: 'pdflatex'

I tried everything - os.system() ... subprocess. Any way I try, it can't find pdflatex. I'm running on Windows, but I need to be able to to do this within the web-app anyway.

Thanks for any help!

DYZ
  • 55,249
  • 10
  • 64
  • 93
spectrum
  • 379
  • 4
  • 11

3 Answers3

1

You just need to install pdflatex (and you will need to install on your server when you release your web-app). Instructions for installing on windows can be found in the top answer here.

jantzl
  • 136
  • 6
0

Do you have texlive installed? If yes, then the issue is with the system path variable. If not already added, add it to the system path.

#

Updated answer:

I took the time and decided to replicate your issue. I too use windows. I copied the basic example from Pylatex and tested it on my machine, I was able to replicate the same error as you despite having TexLive installed. To solve it I did the following steps:

  1. Installed MikTex (I believe you have it installed).
  2. Tried running it again but failed with the error missing package latexmk.
  3. Using MikTex package manager, I installed the latexmk package.
  4. Tried running but still failed, error missing perl.exe command.
  5. I had to install perl to my windows, use the following links -- https://learn.perl.org/installing/windows.html
  6. When I tried again, it compiled successfully.

The issue was not having the package latexmk for MikTex and perl.exe of which you should have posted as part of the error logs. Try that and let me know if successful.

aspo
  • 374
  • 2
  • 9
0

Do you have "pdflatex" installed? As per this question, you may have to install "MiKTeX" and point os.system() at C:\Program Files\MiKTeX <MikTeX version>\miktex\bin to make it work.

Hope that helps.

Ertain
  • 67
  • 11