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.

--noconsole not working #654

Open
Open

Description

@francescofact

Hello, I've built an app with eel and now I'm trying to make an executable from it. But if I try to disable the console it doesn't start and shows the following error:

error

I'm using this command:
python -m eel app.py web --onefile --noconsole --splash splash.png

and from python I just runeel.start('index.html')

I tried to redirect sys.stderr and sys.stdout to a StringIO or a PIPE but still the error popup.
I'm on windows and the app runs with Chrome.

Activity

  1. lucdsouza commented on Dec 19, 2022

    @lucdsouza

    Same here, trying to find a solution or workaround, but no lucky until now... let me know if you find something, please

  2. snopedom commented on Dec 19, 2022

    @snopedom

    @francescofact @lucasadsouza We faced same problem on project. This soulution is not maybe for everyone but as a workaround will help you. Attempt to redirect sys.stderr and sys.stdout somewhere was right way but only redirect to /dev/null works for us.

    Version: eel v0.15.0 with electron
    Cmd: python -m eel main.py web --noconsole --onefile

    import os
    import sys
    
    f = open(os.devnull, 'w')
    sys.stdout = f
    sys.stderr = f
    
    import eel
    
  3. francescofact commented on Dec 19, 2022

    @francescofact
    Author

    Thank you. I also figure out a similar temporary solution.
    Put this snippet at the very top of the code, also Upper then libraries

    import sys, io
    sys.stdout = io.StringIO()
    sys.stderr = io.StringIO()
    
  4. JeswinSunsi commented on Jan 12, 2023

    @JeswinSunsi

    @francescofact @snopedom @lucasadsouza Here's another solution that I used for a project a couple years back. It's working as of November 2022.

    import ctypes
    
    def hideConsole():
        whnd = ctypes.windll.kernel32.GetConsoleWindow()
        if whnd != 0:
            ctypes.windll.user32.ShowWindow(whnd, 0)
    
    hideConsole()
    
  5. woodrow-lwd commented on Jan 29, 2023

    @woodrow-lwd

    Thank you. I also figure out a similar temporary solution. Put this snippet at the very top of the code, also Upper then libraries

    import sys, io
    sys.stdout = io.StringIO()
    sys.stderr = io.StringIO()
    

    it's work for me. just need to write this code snippet before import eel

  6. doug-benn commented on Feb 9, 2023

    @doug-benn
    Contributor

    Hello,

    This is odd because I am using a chrome-app binary created with --noconsole --onefile.

    Works fine for chrome but not edge which I fixed here: #626

    Thanks

    • Doug
  7. davis-andy commented on Mar 15, 2023

    @davis-andy

    I ran into this issue as well and it might be a bottle issue since the screenshot shows from file bottle.py line 73, which shows this:

    72: try:
    73:    _stdout, _stderr = sys.stdout.write, sys.stderr.write
    74: except IOError:
    75:     _stdout = lambda x: sys.stdout.write(x)
    76:     _stderr = lambda x: sys.stderr.write(x)

    using --noconsole causes an AttributeError (probably because the console does not exist so there is nothing to write to)

    I sort of did this in my bottle files before running pyinstaller, which may not be the best solution but was a temp fix that worked for me:

    72: try:
    73:    _stdout, _stderr = sys.stdout.write, sys.stderr.write
    74: except IOError:
    75:     _stdout = lambda x: sys.stdout.write(x)
    76:     _stderr = lambda x: sys.stderr.write(x)
    77: except AttributeError:
    78:     pass

    Not sure what can really be done for it

  8. IshuSinghSE commented on Jul 17, 2024

    @IshuSinghSE

    Thanks for the workaround, You're surely a Hacker 🧑‍💻😁

    ArabicGamerHackerMemeGIF

  9. bwoodsend commented on Jul 28, 2024

    @bwoodsend

    The correct fix is just to check that sys.stdout/sys.stderr aren't None before attempting to use them.

    if sys.stderr:
         sys.stderr.write("...")

    This is in both Python and PyInstaller's documentation.

  10. unpinned this issue on Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions