473,326 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

subprocess.Popen fails, but os.system works

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

Apr 25 '07 #1
1 3555
In <11**********************@n35g2000prd.googlegroups .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
Apr 25 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Uri Nix | last post by:
Hi all, I've been trying to use (Python 2.4 on WinXP) the subprocess module to execute a shell command (nmake in this case), and pass its output to a higher level. Using the following...
3
by: madpython | last post by:
playing with subprocess.Popen on Windows I stumbled into the following problem: Python 2.4.3 (#69, Mar 29 2006, 17:35:34) IDLE 1.1.3 >>> import subprocess >>>...
12
by: Eric_Dexter | last post by:
I am trying to modify a programming example and I am coming up with two problems... first is that I can't seem to pass along the arguments to the external command (I have been able to do that with...
3
by: mclaugb | last post by:
Hello ALl, I have a compiled program "conv.exe" that works as follows: ----------------------------- Please selection from the following options. press "h" for help, "p" for print, "r" for...
12
by: bhunter | last post by:
Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's...
7
by: skunkwerk | last post by:
Hi, i'm trying to call subprocess.popen on the 'rename' function in linux. When I run the command from the shell, like so: rename -vn 's/\.htm$/\.html/' *.htm it works fine... however when I...
8
by: clyfish | last post by:
In cmd, I can use find like this. C:\>netstat -an | find "445" TCP 0.0.0.0:445 0.0.0.0:0 LISTENING UDP 0.0.0.0:445 *:* C:\> And os.system is OK....
4
by: grayaii | last post by:
There are so many threads on this subject, but I ran across a situation on Windows that I can't figure out. I'm trying to run this little command-line exe and when I launch like this, it hangs:...
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.