I am having problems calling pandoc from python using subprocess.Popen. It all works in the console. Here is the code.
# Test markdown file
here is just a simple markdown file.
Now my python code using that filename is the full path my markdown file:
import subprocess
fileout = os.path.splitext(filename)[0] + ".pdf"
args = ['pandoc', filename, '-o', fileout]
subprocess.Popen(args)
I also tried various ways to capture an error but that didn’t work. In the console, however, everything is running fine:
pandoc '[filename]' -o '[fileout]'
That should work just fine, but you may want to wait for it to finish using
subprocess.check_callrather thansubprocess.Popendirectly:This also makes sure that it completed successfully. If the status code isn’t 0, it will throw an exception.