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

Cannot compile to exe with the option "Window based (hide the console)" with auto-py-to-exe AttributeError: 'NoneType' object has no attribute 'write' #739

Open
InfHorus opened this issue Aug 4, 2024 · 1 comment
Labels

Comments

@InfHorus
Copy link

InfHorus commented Aug 4, 2024

Eel version
0.16 and 0.17 both have the issue
Describe the bug
image
Basically when I compile my project using auto-py-2-exe, it can works without issue, however if I compile with the option "Window based (hide the console) it cannot start my exe as it immediately shows the image above:
File "main.py", line 1, in
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "eel_init
.py", line 15, in
import bottle as btl
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "bottle.py", line 73, in
AttributeError: 'NoneType' object has no attribute 'write'

To Reproduce
Compile any project with auto-py-to-exe and check hide the console Window based

Expected behavior
I want to be able to compile it for an actual release so I do not want the console to be shown to the users.

System Information

  • OS: Windows 11
  • Browser: Chrome
  • Python Distribution: 3.11

Screenshots
image

@InfHorus InfHorus added the bug label Aug 4, 2024
@InfHorus
Copy link
Author

InfHorus commented Aug 4, 2024

Managed to make a workaround by redirecting the stdout & stderr doing :

if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
    class StdoutRedirect:
        def __init__(self):
            self.buffer = ''

        def write(self, text):
            self.buffer += text

        def flush(self):
            pass

    sys.stdout = StdoutRedirect()
    sys.stderr = StdoutRedirect() 

But it would be for sure better for people to have an actual fix without the needs for that.

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

No branches or pull requests

1 participant