Subprocess Call works on Windows, but not Ubuntu
bnbowman at gmail.com
Tue Nov 23 21:31:25 CET 2010
Ah, that fixed it. Thank you.
On Tue, Nov 23, 2010 at 11:37 AM, Chris Rebert <clp2 at rebertia.com> wrote:
> On Tue, Nov 23, 2010 at 11:28 AM, Brett Bowman <bnbowman at gmail.com> wrote:
> > I ran into an interesting problem trying to spawn a subprocess, so I
> > I'd ask if the experts could explain it to me. I'm spawning a subprocess
> > run "pdf2txt.py", which is a tool that is distributed with PDFminer to do
> > moderately advanced text-dumps of PDFs. Yet when I run the same code on
> > two dev machines - one Win XP, the other Ubuntu 10.04 or 10.10 - it only
> > works on the former and not the later. And its not terribly complicated
> > code.
> > # Code Start
> > sp_line = 'python pdf2txt.py -p 1 -o %s "%s"' % ('temp.out',
> > print sp_line
> > sp = subprocess.Popen(sp_line)
> > python pdf2txt.py -p 1 -o temp.out "Aarts et al (2009).pdf"
> > That command works on both systems when copied directly to the
> > and the python script it is a part of works on the Windows machine, but I
> > can't the script to work on Ubuntu for the life of me. What am I
> Quoting the docs (for the Nth time; emphasis added):
> On Unix, with shell=False (default): args should normally be a
> sequence. ***If a string is specified for args***, it will be used as
> the name or path of the program to execute; ***this will only work if
> the program is being given no arguments.***
> """ http://docs.python.org/library/subprocess.html#subprocess.Popen
> Fixed version:
> sp_args = ['python', 'pdf2txt.py', '-p', '1', '-o', 'temp.out',
> sp = subprocess.Popen(sp_args)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list