0

I'm building a desktop application using Python, JS, HTML and CSS. I'm connecting python using eel. When I launch my desktop application through the python terminal, it works perfectly.

However, when I launch the app through electron via command line:

$npm start

The desktop application loads up, but it doesn't execute on any of the python backend, explained well by this error in the inspector:

Failed to load resource: net::ERR_FILE_NOT_FOUND eel.js:1

I'm not sure what is causing it, I have spent the last 8 hours testing things but to no avail.

I know you may need more information but I've been checking everything, from file structure i.e. the __.py outside web folder, to inserting <script type="text/javascript" src="/eel.js"></script>, so please comment below what specifically you require as including every possible cause would be a very huge question. I will include whatever is relevant in edits in this question alongside the final answer for anyone with similar issues in the future.

HarrisAMA
  • 37
  • 7
  • Is the URL you're using `file:///eel.js` as shown in the title or just `/eel.js` as shown in the question itself? The latter sounds more likely to be correct (at least from the eel examples I've seen). – Michael Geary Aug 06 '20 at 22:50
  • 1
    I'm using /eel.js in the file. "file:///eel.js" is what appears in the inspector once the app is launched. – HarrisAMA Aug 06 '20 at 23:01
  • Try relative addressing, like `eeldir/eel.js`, check the file permissions, check the letters case – V.Volkov Aug 06 '20 at 23:29
  • It finds the file but then calls a bunch of errors, I've replaced the eel.js file with variations online and the original, problems include the following: Uncaught TypeError: Cannot read property 'length' of undefined (eel.js:70) at Object._mock_py_functions (eel.js:70) at Object._init (eel.js:129) at eel.js:173 – HarrisAMA Aug 06 '20 at 23:50
  • @V.Volkov please note though that it works perfectly fine when launching through python – HarrisAMA Aug 06 '20 at 23:59

1 Answers1

2

No need to run from npm. eel.js is just virtual javascript, dont bother with it. Put this in your your_main.py file

import eel.browsers

asign your electron browser

eel.browsers.set_path('electron', 'node_modules/electron/dist/electron')

and then use it

eel.start('main.html', mode='electron')

to run, call from python:

python your_main.py
Muallim CH
  • 36
  • 2
  • Hi I‘m doing same things now. And I have question if we distribute this electron app then how to include python the app? – wataru Feb 21 '21 at 10:39