I'm trying to run pdflatex on a .tex file from a Python 2.4.4. subprocess (on a mac):
import subprocess
subprocess.Popen(["pdflatex", "fullpathtotexfile"], shell=True)
which effectively does nothing. However, I can run "pdflatex fullpathtotexfile" in the terminal without issues, generating a pdf. What am I missing?
[EDIT] As suggested in one of the answers, I tried:
return_value = subprocess.call(['pdflatex', '/Users/Benjamin/Desktop/directory/ON.tex'], shell =False)
which fails with:
Traceback (most recent call last):
File "/Users/Benjamin/Desktop/directory/generate_tex_files_v3.py", line 285, in -toplevel-
return_value = subprocess.call(['pdflatex', '/Users/Benjamin/Desktop/directory/ON.tex'], shell =False)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/subprocess.py", line 413, in call
return Popen(*args, **kwargs).wait()
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/subprocess.py", line 543, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/subprocess.py", line 975, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
The file does exist and I am able to run pdflatex /Users/Benjamin/Desktop/directory/ON.tex
in the Terminal. Note that pdflatex does throw a good number of warnings... but that shouldn't matter, and this also gives the same error:
return_value = subprocess.call(['pdflatex', '-interaction=batchmode', '/Users/Benjamin/Desktop/directory/ON.tex'], shell =False)