subprocess.Popen fails, but os.system works

B

bahoo

Hi,

I am using Windows + Python 2.5.

This line of code fails (see error message at the end),

last_line = subprocess.Popen(["D:/release/win.exe 0.5 1000 100 D:/
images/img.ppm out.ppm"], stdout=subprocess.PIPE).communicate()[0]

but using "os.system" works:
os.system('D:/release/win.exe 0.5 1000 100 D:/images/img.ppm out.ppm')

----------
C:/Python25/pythonw.exe -u "D:/run.pyw"
Traceback (most recent call last):
File "D:/run.pyw", line 59, in <module>
process_dir(mydir)
File "D:/run.pyw", line 52, in process_dir
segmentation (dir,f)
File "D:/run.pyw", line 35, in segmentation
last_line = subprocess.Popen(["D:/release/win.exe 0.5 1000 100 D:/
images/img.ppm out.ppm"], stdout=subprocess.PIPE).communicate()[0]
File "C:\Python25\lib\subprocess.py", line 593, in __init__
errread, errwrite)
File "C:\Python25\lib\subprocess.py", line 793, in _execute_child
startupinfo)
WindowsError: [Error 22] The filename, directory name, or volume label
syntax is incorrect
 
M

Marc 'BlackJack' Rintsch

This line of code fails (see error message at the end),

last_line = subprocess.Popen(["D:/release/win.exe 0.5 1000 100 D:/
images/img.ppm out.ppm"], stdout=subprocess.PIPE).communicate()[0]

but using "os.system" works:
os.system('D:/release/win.exe 0.5 1000 100 D:/images/img.ppm out.ppm')

----------
C:/Python25/pythonw.exe -u "D:/run.pyw"
Traceback (most recent call last):
File "D:/run.pyw", line 59, in <module>
process_dir(mydir)
File "D:/run.pyw", line 52, in process_dir
segmentation (dir,f)
File "D:/run.pyw", line 35, in segmentation
last_line = subprocess.Popen(["D:/release/win.exe 0.5 1000 100 D:/
images/img.ppm out.ppm"], stdout=subprocess.PIPE).communicate()[0]
File "C:\Python25\lib\subprocess.py", line 593, in __init__
errread, errwrite)
File "C:\Python25\lib\subprocess.py", line 793, in _execute_child
startupinfo)
WindowsError: [Error 22] The filename, directory name, or volume label
syntax is incorrect

You are trying to execute a program named::

D:/release/win.exe 0.5 1000 100 D:/images/img.ppm out.ppm

Such a program does not exist on your computer. ;-)

Give `subprocess.Popen()` a list with the program name and the individual
arguments as elements instead.

Ciao,
Marc 'BlackJack' Rintsch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top