Eel icon indicating copy to clipboard operation
Eel copied to clipboard

How to use eel with electron using mode='electron'?

Open SoumyaRanjanPatnaik opened this issue 4 years ago • 6 comments
trafficstars

Hello!! I only have very little knowledge about node.js, so I could not use electron. But eel seems pretty easy to get started with. My system only has firefox installed, so the program I wrote didn't run initially. And although using mode = 'chrome-app' allowed me to run the app, it opens as a new tab on my browser. I was going through the documentation just now, and I saw the following line that really got me excited:

mode, a string specifying what browser to use (e.g. 'chrome', 'electron', 'edge', 'custom'). Can also be None or False to not open a window. Default: 'chrome'

So, I installed electron using npm and wrote the following dummy code to check if it works.

import eel
PORT = 8001

eel.init("./static")

@eel.expose
def print_booking_status(x, date):
    if(x==True):
        print(f"Booked Successfully for date {date}")
    else:
        print("Booking Cancelled");

eel.start("index.html", mode='electron', port=PORT)

But I'm getting an error that says electron installation was not found.

OSError: Can't find Electron installation

I also tried a global installation of electron, but it still didn't work. Can anyone provide any suggestions to run my code through electron? And is it even possible?

  • [x] I know that if I don't provide a sample code that allows someone to quickly step into my shoes, I may not get the help I want or my issue may be closed.

Desktop (please complete the following information):

  • OS: GNU Linux (Pop!_OS)
  • Browser: Firefox
  • Version: 88.0.1

SoumyaRanjanPatnaik avatar May 31 '21 20:05 SoumyaRanjanPatnaik

To use electron with eel try checking the example below: https://github.com/ChrisKnott/Eel/tree/master/examples/09%20-%20Eelectron-quick-start

Muhammad-Taif-Khan avatar Jun 21 '21 17:06 Muhammad-Taif-Khan

when i package this example with pyinstaller it stops working at first the error was that it couldn't find electron.exe so I moved electron to the web directory and now electron shows that it couldn't find main.js

technoo0 avatar Jul 14 '21 09:07 technoo0

import eel
import eel.browsers

eel.init('web')
eel.browsers.set_path('electron', 'node_modules/electron/dist/electron')
eel.start('web/index.html', mode='electron')

like this 😁

mouadessalim avatar Aug 05 '21 00:08 mouadessalim

For me, this works until I try to build. Then I get the following. Any clue? When I look inside the Contents of the application package, I see no trace of node_modules or Electron (like in Atom.app, for example). It looks like PyInstaller isn't bundling the node modules.

Traceback (most recent call last): File "lbg_eel.py", line 12, in File "eel/init.py", line 158, in start File "eel/init.py", line 186, in show File "eel/browsers.py", line 63, in open File "eel/electron.py", line 11, in run File "subprocess.py", line 951, in init File "subprocess.py", line 1821, in _execute_child FileNotFoundError: [Errno 2] No such file or directory: 'node_modules/electron/dist/Electron.app/Contents/MacOS/Electron' [10015] Failed to execute script 'lbg_eel' due to unhandled exception: [Errno 2] No such file or directory: 'node_modules/electron/dist/Electron.app/Contents/MacOS/Electron' [10015] Traceback: Traceback (most recent call last): File "lbg_eel.py", line 12, in File "eel/init.py", line 158, in start File "eel/init.py", line 186, in show File "eel/browsers.py", line 63, in open File "eel/electron.py", line 11, in run File "subprocess.py", line 951, in init File "subprocess.py", line 1821, in _execute_child FileNotFoundError: [Errno 2] No such file or directory: 'node_modules/electron/dist/Electron.app/Contents/MacOS/Electron'

Saving session... ...copying shared history... ...saving history...truncating history files... ...completed.

max-uho avatar Oct 21 '21 18:10 max-uho

I'm sorry for telling you that there is no solution we can't build eel, for my experience i tried with cx_freeze and pyinstaller with no solution, so what i did is to use electron directly like main and using python like backend with js module(child_process) you can interact with python you can check my repository, i am actually using that here and it's easier for deployment.

mouadessalim avatar Nov 02 '21 17:11 mouadessalim

yea i cant build eel with electron

myudak avatar May 17 '22 15:05 myudak