question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Failed to execute script" when executing a pyinstaller noconsole exe that uses electron

See original GitHub issue

Eel 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:

  1. Compile electron using electron-builder
  2. Compile the exe using pyinstaller: python -m eel ./src/main.py ./src/web/ --add-data="./dist/electron/;./electron/" --noconsole
  3. 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:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

4reactions
JeswinSunsicommented, Aug 16, 2020

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.

def hideConsole():
  whnd = ctypes.windll.kernel32.GetConsoleWindow()
  if whnd != 0:
     ctypes.windll.user32.ShowWindow(whnd, 0)

Then call hideConsole() somewhere in your script. Dont forget to import ctypes.

2reactions
MikeKarnscommented, Jan 20, 2021

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] )

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Failed to execute script" when executing a pyinstaller ...
"Failed to execute script" when executing a pyinstaller noconsole exe that uses electron #213. Open. ahobsonsayers opened this issue on Nov ...
Read more >
Pyinstaller Error "failed to execute script " When App Clicked ...
... to successfully run the program using normal python command as well as successfully run pyinstaller and be able to execute the app...
Read more >
Pyinstaller "Failed to execute script" error with --noconsole ...
This script runs fine when executed with the python interpreter; it connects back to a server on a different machine using an HTTP...
Read more >
Using Spec Files - PyInstaller
However, the first script named supplies the name for the spec file and for the executable folder or file. Its code is the...
Read more >
Using PyInstaller (or similar) to create an executable - Streamlit
3 Likes. Creating Deployable Exe Without Streamlit Sharing ... After all that, you can run your script using the usual python call python ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found