Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] problem using --noconsole flag #698

Open
Saulo-Felipe opened this issue Aug 20, 2023 · 3 comments
Open

[BUG] problem using --noconsole flag #698

Saulo-Felipe opened this issue Aug 20, 2023 · 3 comments

Comments

@Saulo-Felipe
Copy link

Saulo-Felipe commented Aug 20, 2023

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

image

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
@Nriver
Copy link

Nriver commented Aug 21, 2023

related issue #654

@ajmirsky
Copy link

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.

@chrislilley13
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants