Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > subprocess.Popen fails, but os.system works

Reply
Thread Tools

subprocess.Popen fails, but os.system works

 
 
bahoo
Guest
Posts: n/a
 
      04-25-2007
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
-----------

Can anyone tell me why?
Thanks
bahoo

 
Reply With Quote
 
 
 
 
Marc 'BlackJack' Rintsch
Guest
Posts: n/a
 
      04-25-2007
In <(E-Mail Removed) .com>, bahoo wrote:

> 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
> -----------
>
> Can anyone tell me why?


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: same DLL (ASP.NET), but include only works for aspx but not fo David Wang ASP .Net 0 12-01-2006 01:42 AM
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
[py2exe.i18n] English works, German works, but not French. What do I miss? F. GEIGER Python 3 08-06-2004 10:01 AM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM



Advertisments