I have the situation that I want the job done from eclipse so I use eclipse's .launch configuration . I tried to make it run python directly but got error: error 193 (%1 is not a valid Win32 app)
. where %1 is probably my python script.
I decided to create a simple batch script that calls this big wild python animal.
I did a lot of combinations and found this the best (batch outputs some strings, runs python, waits for it, the outputs some strings again):
start /b /wait "Python_script.py" "%1" "%2" "%3" "%4" "%5"
It worked until python itself started to run exe file.
Once again I tried a lot of combinations:
os.system([exe, arg1, arg2, ...])
and subprocess.call(..)
and subprocess.check_output(..)
-> I either didn't see the output in eclipse console, or the output was delayed or there was only python / or only exe's output in console.
finally I used subprocess.Popen(...)
and it's nearly allright - the only defect is that the output from python script don't wait for exe's process to finish, and when I use subprocess.Popen(...).wait()
exe passes output to console but the WHOLE output from python script is delayed until the 'exe' terminates . I want to delay only the part of pythons script output that is written after the exe is called.
Thanks!
It sounds to me like you have three different processes you're trying to get to work together, you've tried a whole bunch of stuff to get it working, and the code is complex enough that you can't easily post it here. That makes it pretty hard to get a good answer (Stack Overflow works much better with focused questions), but here's the general approach I'd take:
Python_script.py
directly from the command prompt?
start
; just replace Python_script.py
in your launch configuration with c:\\Python27\\python.exe Python_script.py
(or similar). subprocess.call
, subprocess.check_output
, and Popen
all have different uses, so it's hard to give general advice besides just referring to the documentation .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.