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]'
This doesn't answer your question (and you may specifically want/need to call pandoc using subprocess.Popen) but there is a Python wrapper for Pandoc called Pyandoc: see my answer here.
That should work just fine, but you may want to wait for it to finish using subprocess.check_call
rather than subprocess.Popen
directly:
subprocess.check_call(args)
This also makes sure that it completed successfully. If the status code isn't 0, it will throw an exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With