Closed kochjar closed 1 year ago
Me too
Edit: When using --noconsole
, sys.stdout + sys.stderr
are NullWriter
s and sys.__stdout__ + sys.__stderr__
are None
s. Because bottle
, a module used by eel
, is using them, all you need to do is redirect them, for an instance to a file, at the start of your main script.
import sys
if hasattr(sys, "_MEIPASS"): # if the script is started from an executable file
with open("logs.txt", "a") as f_logs:
sys.stdout = f_logs
sys.stderr = f_logs
I am building an python project with Eel, and I'm trying to package my program to an exe with PyInstaller as instructed in the documentation. However, I get the following error when I open the .exe:
Traceback (most recent call last): File "hello.py", line 1, in <module> import eel File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module File "eel\__init__.py", line 8, in <module> File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module File "bottle.py", line 73, in <module> AttributeError: 'NoneType' object has no attribute 'write'
I tried to use auto py-to-exe instead of Pyinstaller, but I got the same error. Finally, I tried to package the Eello world example from the Eel documentation to see if it was my program that was the issue, but I still got the same error. I found a similiar problem in a github issue, but I fail to see what I should attach to --add-data.
I am running Python 3.10.8 and Eel 0.14.0. I've now tried python 3.8.9 and python 3.9.13 without luck.
Upon further investigation, I discovered that the error only occours when I attach
--noconsole
at the end of my cmdpython -m eel hello.py web --onefile --noconsole
. However, I want my app to work without a visible console.