Search code examples
pythonpyinstaller

How to run Python".exe" not Spawned, as it is by >python "myscript.py"


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()


Solution

  • 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).