Opening PDF Using subprocess.Popen Failing

Robin Becker robin at reportlab.com
Mon Jun 22 06:33:47 EDT 2015


.....

Naftali,

I ran the following from python prompt


import os
os.system('"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /n 
thello.pdf')


and this worked as did

import subprocess
subprocess.Popen(['C:\Program Files (x86)\Adobe\Reader 
11.0\Reader\AcroRd32.exe','/n','thello.pdf'])

however I also tried running

import subprocess
subprocess.Popen('AcroRd32.exe /nthello.pdf')

which seems closer to your

> new_command_str = "AcroRd32.exe /n" + outputname
> subprocess.Popen(new_command_str)

and that fails; the python error is


> C:\Users\rptlab\tmp>tpdf.py
> Traceback (most recent call last):
>   File "C:\Users\rptlab\tmp\tpdf.py", line 6, in <module>
>     subprocess.Popen('AcroRd32.exe /nthello.pdf')
>   File "c:\python27\lib\subprocess.py", line 710, in __init__
>     errread, errwrite)
>   File "c:\python27\lib\subprocess.py", line 958, in _execute_child
>     startupinfo)
> WindowsError: [Error 2] The system cannot find the file specified



-- 
Robin Becker



More information about the Python-list mailing list