subprocess.Popen(cmd) does not find command that can be run in Terminal

1.6k views Asked by At

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.

1

There are 1 answers

2
Mike Müller On BEST ANSWER

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

subprocess.Popen(['pdflatex'], shell=True)