"Failed to execute script" when executing a pyinstaller noconsole exe that uses electron
See original GitHub issueEel version v0.11
Describe the bug When executing a pyinstaller exe that was compiled using the --noconsole option and which makes use of electron, the app crashes with the error “Failed to execute script”
To Reproduce Steps to reproduce the behaviour:
- Compile electron using electron-builder
- Compile the exe using pyinstaller:
python -m eel ./src/main.py ./src/web/ --add-data="./dist/electron/;./electron/" --noconsole
- Execute the exe
Expected behaviour App works as usual
Error Output By including the following code at the top of the python file:
import sys
sys.stderr = open("error.log", "a")
The following output was observed:
Traceback (most recent call last):
File "src\MesIntegration.py", line 196, in <module>
File "lib\site-packages\eel\__init__.py", line 134, in start
File "lib\site-packages\eel\__init__.py", line 156, in show
File "lib\site-packages\eel\browsers.py", line 63, in open
File "lib\site-packages\eel\electron.py", line 11, in run
File "subprocess.py", line 728, in __init__
File "subprocess.py", line 1057, in _get_handles
AttributeError: 'NullWriter' object has no attribute 'fileno'
Possible Fix
I was able to stop the app crash by changing line 11 of electron.py to:
sps.Popen(cmd, stdout=sps.PIPE, stderr=sps.PIPE, stdin=sps.PIPE)
It seems a statement needs to be added that can recognise when the app is being run without a console and set stdout and stderr to sps.PIPE.
If anyone can suggest a way we might to do this, i would be willing to submit a pull request.
In the meantime using mode=“custom” in eel.start() solves the crash as id prefer not to change library files
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6
Top GitHub Comments
Yes this happened to me too. Somehow the --noconsole flag causes this. I’ve found out a possible workaround for this that works fine though.
Then call hideConsole() somewhere in your script. Dont forget to import ctypes.
Hi,
I am also having this issue. I believe the original poster has the issue correct. Just need to route stdout and stdin when being used without a console.
I was able to use a similar workaround to @ahobsonsayers, @g-berthiaume this may interest you…
eel.start( index.html, mode='custom' cmdline_args=[electron_path, .\index.js] )