Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting rid of console output when freezing Python programs using Pyinstaller

I have recently written a fairly simple program for my grandfather using Python with GUI from Tkinter, and it works beautifully for what he will be using it for. However, there is, of course, the ugly console output window. I have successfully gotten rid of it by simply changing the extension of the file from .py to .pyw. When I freeze it using PyInstaller, it reappears again! Is there any way for me to fix this?

Thanks in advance.

like image 405
dfreeze Avatar asked Jul 11 '13 03:07

dfreeze


People also ask

How do I get rid of the console in PyInstaller?

We can hide or avoid the console by specifying pyinstaller --oneline filename --windowed command.

How do I hide the console window in Python?

Simply save it with a . pyw extension. This will prevent the console window from opening.

What is the output of PyInstaller?

Bundling to One Folder When you apply PyInstaller to myscript.py the default result is a single folder named myscript . This folder contains all your script's dependencies, and an executable file also named myscript ( myscript.exe in Windows).

Why is the .EXE file created by PyInstaller not working?

The most common reason a PyInstaller package fails is that PyInstaller failed to bundle a required file. Such missing files fall into a few categories: Hidden or missing imports: Sometimes PyInstaller can't detect the import of a package or library, typically because it is imported dynamically.


1 Answers

If you want to hide the console window, here is the documentation: This is how you use the --noconsole option

python pyinstaller.py --noconsole yourscript.py 

If you need help using pyinstaller to get to the point where you need to use the --noconsole option here is a simple tutorial for getting there.

like image 97
Stephan Avatar answered Oct 08 '22 04:10

Stephan