All,

Another programmer helped me find a nice approach that still uses the newer
subprocess module. Is there a good place to post this on the Pyinstaller
site? I hope that it can help others who stumble across the same problem.
This works directly from Python, and from the pyinstaller binary, and from
the pyinstaller binary when using --noconsole.

import subprocess
with open('out.txt', 'w') as f:
    try:
        si = subprocess.STARTUPINFO()
        si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        h = subprocess.check_output(['python', '--help'],
            stdin=subprocess.PIPE,
            stderr=subprocess.PIPE,
            startupinfo=si)
        f.write(h)
    except OSError as e:
        f.write('Failed: ' + str(e))


On Sat, Jan 11, 2014 at 1:47 PM, Michael Hipp <[email protected]> wrote:

> Have you tried calling it something like this:
> Popen(cmd, creationflags=win32process.CREATE_NO_WINDOW)
>
>
> On Fri, Jan 10, 2014 at 3:00 PM, Bryan A. Jones <[email protected]>wrote:
>
>> All,
>>
>> I'm stuck with a Pyinstaller problem (Windows 7, latest pyinstaller from
>> git, Python 2.7). I'd like to create an application without a console
>> window, so I pass --noconsole to pyinstaller. However, I also call some
>> external programs from my application, which is causing problems:
>>
>>    1. If I use subprocess.call and friends, I get the exception OSError
>>    exception "[Error 6] the handle is invalid." This is because a noconsole
>>    app has no stdin/stdout/stderr; by default, subprocess tries to pass these
>>    on to the child process, which fails.
>>    2. If I use subprocess.call with stdin=PIPE, stdout=PIPE, stderr=PIPE
>>    (which opens a pipe between the child process and my parent Python
>>    process), everything works, but I get a command window that appears 
>> briefly
>>    on the screen. Because I call this child process a lot, I see a lot of
>>    distracting consoles opening and closing.
>>    3. Trying op.spawnl produces identical results to #2.
>>
>> All the code works fine when running without --noconsole or running
>> directly from Python. Any ideas on how to run a child subprocess
>> successfully, but without opening a console window?
>>
>> Thanks!
>>
>> Bryan
>> --
>> Bryan A. Jones, Ph.D.
>> Associate Professor
>> Department of Electrical and Computer Engineering
>> 231 Simrall / PO Box 9571
>> Mississippi State University
>> Mississippi state, MS 39762
>> http://www.ece.msstate.edu/~bjones
>> bjones AT ece DOT msstate DOT edu
>> voice 662-325-3149
>> fax 662-325-2298
>>
>> Our Master, Jesus Christ, is on his way. He'll show up right on
>> time, his arrival guaranteed by the Blessed and Undisputed Ruler,
>> High King, High God.
>> - 1 Tim. 6:14b-15 (The Message)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PyInstaller" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/pyinstaller.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "PyInstaller" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/pyinstaller.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Bryan A. Jones, Ph.D.
Associate Professor
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi state, MS 39762
http://www.ece.msstate.edu/~bjones
bjones AT ece DOT msstate DOT edu
voice 662-325-3149
fax 662-325-2298

Our Master, Jesus Christ, is on his way. He'll show up right on
time, his arrival guaranteed by the Blessed and Undisputed Ruler,
High King, High God.
- 1 Tim. 6:14b-15 (The Message)

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to