0

After creating the ".exe" from "myscript.py" by the command line:

pyinstaller --onefile -w myscript.py

i see that windows 10 spawn the process, it does not wait for the execution as it usually do if i execute as original script by the command line:

python myscript.py

So, how to run the ".exe" as it runed by python ???? Not spawing it.

Also no "print()" prints anything what i guess that it is because the main output port has been changed by the spawning stuff...

myscript.py

import sys


def main():
    print('Hello World!') 
    sys.stdout.flush()


main()

3
  • How can you even tell it's not waiting? That program should complete in about a microsecond. Commented Sep 7, 2021 at 16:40
  • @MarkRansom What they are referring to is that a program that has its subsystem set to "GUI" in its PE header will not get the parent console I/O inherited and cmd and powershell also won't wait for its execution to finish unlike they do for programs with the subsystem set to "Console". Commented Sep 7, 2021 at 23:03
  • @CherryDT I'm glad you can make some sense of this question, because I can't. Commented Sep 7, 2021 at 23:15

1 Answer 1

1

You specifically asked for this behavior through -w (--windowed):

Windows and Mac OS X: do not provide a console window for standard i/o.

Don't use -w if you want a CLI program (and you are using the console). Use -w if you want a GUI program (and you are showing your own dialog windows and such).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.