Eel
Eel copied to clipboard
[BUG] problem using --noconsole flag
Describe the problem
I'm having problems whenever I use the --noconsole
flag. When I create the executable just using --onefile
everything works correctly, however, the terminal opens every time I run the .exe executable (which is a problem). I hope you can help me with this problem, I'll leave the image of the error that occurs whenever I have to run the executable created with the --noconsole
flag.
- OS: windows 11
- Browser chrome
UPDATE 1: I created a simple project from scratch with just the eel library, a single python file and a simple html file and when using --noconsole the same problem I described in the image above occurred, which leads me to believe that it is an error in the Library. I need urgent help, because I bet all the development of my project on this library. Thank you for any help.
UPDATE 2: I managed to work around the problem but not solve it. I used the following:
import os
import sys
f = open(os.devnull, 'w')
sys.stdout = f
sys.stderr = f
related issue https://github.com/python-eel/Eel/issues/654
The terminal opening is a side-effect of an underlying issue that eel can't instantiate correctly. Even if you redirect the output to a file to prevent the console from opening, eel will most likely have trouble running. Eel uses pyinstaller
to create a .spec
file and build into a standalone application; line 15 of __init__.py
is the import of bottle
so the problem is somewhere in how pyinstaller
is packaging your app, not necessarily with eel directly.
Also, redirecting stdout
or stderr
will likely mask a problem if your application does have a failure. Better practice is to configure python logging to redirect exceptions to a log file. print
should be turned into logger.info
or logger.debug
so that you have insight into your running application.
I had the same issue. Only I modified the bottle.py file online 73 like this: try: _stdout = sys.stdout.write if sys.stdout is not None else lambda x: None _stderr = sys.stderr.write if sys.stderr is not None else lambda x: None except AttributeError: _stdout = lambda x: None _stderr = lambda x: None
to properly handle my custom logger. After that my noconsole builds were working.