pdftotext can't find any of the files to convert when called within a python script
i have a python script which keeps crashing on:
subprocess.call(["pdftotext", pdf_filename])
the error being:
OSEr开发者_运维百科ror: [Errno 2] No such file or directory
the absolute path to the filename (which i am storing in a log file as i debug) is fine; on the command line, if i type pdftotext <pdf_filename_goes_here>
it works for any of the alledgedly bad file names. but when called using subprocess
in python i keep getting that error.
what is going on???
also, i tried on the python interpreter, and it worked!
>>> import subprocess
>>> subprocess.call(["pdftotext", "/path/to/file/test.pdf"])
0
>>>
update: just to make it known to everyone, i also tried:
subprocess.call(["/usr/bin/pdftotext", "/path/to/file/test.pdf"])
which also gave the same error. and ive used /usr/bin/pdftotext test.pdf
directly and it worked so i know that's the correct path to the pdftotext executable. any other suggestions?
You'll also get that error if it can't find the executable on path...try using a full path to pdftotext as well, and look at how the $PATH for subprocess.call is set.
精彩评论