1

For the context: I am on macOS, developing with Spyder. I installed TeX with MACTeX.

I am working on creating an automatic text document and I like to use the solution proposed here: Generating pdf-latex with python script

When excecuting the python script in Spyder, I hang on the line calling "subprocess.Popen(cmd)". The error is:

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

If I try to execute the command pdflatex in Terminal, it finds the command and executes it flawlessly.

I probably have a path missing or something similar, though I am puzzled my the error message as it mentions as missing file and I would expect a missing command.

Community
  • 1
  • 1
MAC
  • 419
  • 3
  • 9

1 Answers1

1

You need to set shell=True to get the right shell settings:

subprocess.Popen(['pdflatex'], shell=True)
Mike Müller
  • 82,630
  • 20
  • 166
  • 161
  • Ok, I went from error to error :D. The first I got when using the solution is an error 127 (command not found) that I solved giving the command full path "/Library/TeX/texbin/pdflatex" that is found with the command "which pdflatex" in Terminal. I now face error 1... still digging. – MAC Dec 24 '16 at 12:51
  • Ok, I went to the end of it. One of my issues is that I had is that I used tcsh as the default shell on macOS. I changed it to bash (which is normal for current OSX versions). Now using the full path to call pdflatex as indicated above executes fine with no errors. – MAC Dec 24 '16 at 14:39