Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.
This repository was archived by the owner on Jun 22, 2025. It is now read-only.

[BUG] problem using --noconsole flag #698

Open

Description

@Saulo-Felipe

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

Activity

  1. Nriver commented on Aug 21, 2023

    @Nriver

    related issue #654

  2. ajmirsky commented on Aug 23, 2023

    @ajmirsky

    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.

  3. chrislilley13 commented on Oct 31, 2023

    @chrislilley13

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions