python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.44k stars 587 forks source link

Not being able to make Eel work with Electron #334

Closed Andres-celi closed 4 years ago

Andres-celi commented 4 years ago

Hello, I have been trying to get Eel to run on Electron with no luck.

import eel options = { 'mode': 'custom', 'args': ['node_modules/electron/dist/electron.exe', '.'] } if __name__ == "__main__": eel.init('app') eel.start('index.html',mode='electron')

Options are not being used anymore because of the update. But I get the following error:

Traceback (most recent call last): File "/home/pi/main.py", line 298, in eel.start('index.html',mode='electron') File "/home/pi/.local/lib/python3.5/site-packages/eel/init.py", line 142, in start show(*start_urls) File "/home/pi/.local/lib/python3.5/site-packages/eel/init.py", line 170, in show brw.open(start_urls, _start_args) File "/home/pi/.local/lib/python3.5/site-packages/eel/browsers.py", line 64, in open browser_module.run(path, options, start_urls) File "/home/pi/.local/lib/python3.5/site-packages/eel/electron.py", line 11, in run sps.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=sps.PIPE) File "/usr/lib/python3.5/subprocess.py", line 640, in init errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "/usr/lib/python3.5/subprocess.py", line 1135, in _get_handles c2pwrite = stdout.fileno() io.UnsupportedOperation: fileno

I have gone through the various posts in here and well. Nothing has worked for me so far. I would love some help.

Thank you

samuelhwilliams commented 4 years ago

Hi @Andres-celi. Based on the example here, it looks like you should be passing in options as eel.start('index.html', options=options). At the moment you're creating an options dict but not using it anywhere.

This might give you deprecation warnings, though. You should probably go for the following:

eel.start('index.html', mode='custom', cmdline_args=['node_modules/electron/dist/electron.exe', '.'])

Andres-celi commented 4 years ago

Hi @samuelhwilliams thanks for the response. As I mentioned, among others, I tried that approach too. If I use the following:

eel.init('app1') eel.start('index.html',mode='custom', cmdline_args=['node_modules/electron/dist/electron.exe', '.'])

I get this: Traceback (most recent call last): File "/home/pi/main.py", line 298, in eel.start('index.html', mode='custom', cmdline_args=['node_modules/electron/dist/electron.exe', '.']) File "/home/pi/.local/lib/python3.5/site-packages/eel/init.py", line 142, in start show(*start_urls) File "/home/pi/.local/lib/python3.5/site-packages/eel/init.py", line 170, in show brw.open(start_urls, _start_args) File "/home/pi/.local/lib/python3.5/site-packages/eel/browsers.py", line 53, in open stdout=sps.PIPE, stderr=sps.PIPE, stdin=sps.PIPE) File "/usr/lib/python3.5/subprocess.py", line 676, in init restore_signals, start_new_session) File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'node_modules/electron/dist/electron.exe'

and this is the path contents:

pi@alba2:~/app1/node_modules/electron/dist $ ls chrome_100_percent.pak libGLESv2.so resources.pak chrome_200_percent.pak libvk_swiftshader.so snapshot_blob.bin chrome-sandbox libvulkan.so swiftshader electron LICENSE v8_context_snapshot.bin icudtl.dat LICENSES.chromium.html version libEGL.so locales vk_swiftshader_icd.json libffmpeg.so resources

electron is in there :/

Andres-celi commented 4 years ago

On the other hand, if I use this:

eel.init('app1') eel.start('index.html', mode='custom', cmdline_args=['/home/pi/app1/node_modules/electron/dist/electron', '.'])

it runs and then nothing. No errors and no app either. Is this an improvement? Not really sure Lol.

ChrisKnott commented 4 years ago

I think this is just a .bat script which points to the actual .exe. Popen needs the path to the .exe, it can't deal with the .bat

I thought the mode='electron' should deal with all this though... You shouldn't need to specify the path yourself. Are you in the latest version?

ChrisKnott commented 4 years ago

Sorry wait are you on Mac? (Got confused by the .exe ref).

Either way, it should work to just say mode='electron' with no further options

Andres-celi commented 4 years ago

Hello @ChrisKnott , my bad for not clarifying. I am using a Raspberry Pi 3 B+. When I use mode='electron' I get the following error:

Traceback (most recent call last): File "/home/pi/main.py", line 299, in eel.start('index.html',mode='electron') File "/home/pi/.local/lib/python3.5/site-packages/eel/init.py", line 142, in start show(*start_urls) File "/home/pi/.local/lib/python3.5/site-packages/eel/init.py", line 170, in show brw.open(start_urls, _start_args) File "/home/pi/.local/lib/python3.5/site-packages/eel/browsers.py", line 64, in open browser_module.run(path, options, start_urls) File "/home/pi/.local/lib/python3.5/site-packages/eel/electron.py", line 11, in run sps.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=sps.PIPE) File "/usr/lib/python3.5/subprocess.py", line 640, in init errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "/usr/lib/python3.5/subprocess.py", line 1135, in _get_handles c2pwrite = stdout.fileno() io.UnsupportedOperation: fileno

So the way I went is the following:

eel.init('app1') eel.start('index.html',block=False, mode='custom', cmdline_args=['/home/pi/app1/node_modules/electron/dist/electron', '.']) os.system('electron app1/main.js --disable-gpu'+ " &")

this starts the webserver on python, but then opens the electron app from cmd line. It works but I was wondering if the app should open by itself?. By the way I am using the last version available of eel.

ChrisKnott commented 4 years ago

Are you using IDLE?

samuelhwilliams commented 4 years ago

I'm going to close this now based on inactivity. It does seem to be an IDLE error from quick googling ... hopefully you've found and fixed the problem now.