0

I have a python script that automates some excel work for me. I'm currently using VSCode.

I've installed PyInstaller and created a .exe file which runs the script.

I'd like to open a windows cmd prompt and print completed or the likes.

When I run this from VSCode it outputs to the integrated terminal - no problem. From the .exe file nothing shows...

I'd like a way to open a separate (none integrated window) and print some text if anyone could point me in the right direct.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Robt800
  • 29
  • 7

1 Answers1

0

You can use --console or -c option when running pyinstaller for your script. More info here.

This allows you to show console window and you can use print statements in your script.

Example:

pyinstaller --console myscript.py

If you have already built an .exe, you can update the .spec file..

You would need to add console=True parameter to the EXE method, example:

exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='main',
          debug=False,
          strip=False,
          console=True)

and then run:

pyinstaller your_script.spec

Related links:

https://www.reddit.com/r/learnpython/comments/6b8s7c/will_the_effects_of_print_statements_be_visible/

Getting rid of console output when freezing Python programs using Pyinstaller

https://github.com/chriskiehl/Gooey/issues/235

Rithin Chalumuri
  • 1,739
  • 7
  • 19
  • 1
    worked like a treat, just needed to add `input("Press To Continue")` to bottom of code to ensure window stayed visible to user. Thanks a lot – Robt800 Oct 29 '19 at 17:58