Eel
Eel copied to clipboard
Electron package
I love this project, it becomes so easy to develop beautiful GUI for python apps and the abstraction is great. In my last project, I switched from the Chrome browser to Electron so I could customise the windows appearance and behaviour. It works almost flawlessly; I can't package the app anymore.
I also tried to use a local Electron release and use relative paths
# eel.browsers.set_path('electron', 'node_modules/electron/dist/Electron.app/Contents/MacOS/electron')
eel.browsers.set_path('electron', 'Electron.app/Contents/MacOS/electron')
And tried adding the Electron app to the pyinstaller command:
python3 -m eel main.py web --noconfirm --noconsole --onefile \
--add-data /AbsolutePathTo/Electron.app:Electron.app \
--add-data electron_main.js:Electron.app/Contents/Resources/app
My different tries result in different errors such as
FileNotFoundError: [Errno 2] No such file or directory: 'Electron.app/Contents/MacOS/electron': 'Electron.app/Contents/MacOS/electron'
()
or
Cannot find module '/Users/xyz'. Require stack: /usr/local/lib/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js
I started from the Eelectron example with macOS 10.15 / python 3.7.7 / pyinstaller 3.6
Has anyone achieved this and is willing to help me?
did you reach somewhere regarding packaging??
Same here but in windows.
When packaging (without --onefile), there exists a file in \node_modules\electron\dist\resources\
named default_app.asar
with ~100kb.
If I remove that file and then create a folder with the same name with the main.js
inside, the app neither run nor any message is shown nor in windows cmd.
Getting similar issues.
I can get the distributed exe --onefile
to run from the cmd line on my personal computer, let me know if this is more luck than you've had and I can reproduce my steps.
My issues are:
- unable to run directly from the distributed exe
--onefile
- I get the
Require stack:...
...main.js
error
- I get the
- unable to run .exe on another system
- Can't find Electron error
Trying to solve this currently, will update. Any help appreciated too.
Getting similar issues.
I can get the distributed exe
--onefile
to run from the cmd line on my personal computer, let me know if this is more luck than you've had and I can reproduce my steps.My issues are:
unable to run directly from the distributed exe
--onefile
- I get the
Require stack:...
...main.js
errorunable to run .exe on another system
- Can't find Electron error
Trying to solve this currently, will update. Any help appreciated too.
hello i know this is long time but did you find the solution for this?
@mrsachou ended up have no luck with the electron implementation, ended up using the chromium approach with Eel, I would definitely recommend trying that out if you're not locked into Electron.
Packaging up and distributing was easily done with just pyinstaller
Some lucky here, I was able to package it using python -m eel --add-data="main.js;." --add-data="node_modules;node_modules" --add-data="package-lock.json;." --add-data="package.json;." --noconfirm main.py web
this error you guys are getting because it's missing package-lock.json and package.json
but when I try use --onefile
I get this error when executing the exe :v
I was able to get a working distributable app on MacOS. I had to add data to my spec file so that eel's node_modules would be included as mentioned above.
My spec file looks like this:
import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5)
block_cipher = None
a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[('/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/eel/eel.js', 'eel'), ('web', 'web'), ('node_modules', 'node_modules'), ("package.json", "."), ("package-lock.json", ".")],
hiddenimports=['bottle_websocket'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='main',
)
The datas=[('/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/eel/eel.js', 'eel'), ('web', 'web'), ('node_modules', 'node_modules'), ("package.json", "."), ("package-lock.json", ".")]
allows for pyinstaller to include the node_module, package.json, and package-lock.json inside the app.
To run the spec file enter pyinstaller name.spec
in the CLI.
After pyinstaller finished, I ran my app ./dist/main/main
in the CLI.
I got an error message saying the app couldn't find the file libffmpeg.dylib
and the different paths it tried to look for the file.
So then I found the file, libffmpeg.dylib
, in the path
node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Libraries/libffmpeg.dylib
and copy pasted it to the one of the paths the app was searching for.
Which was the Frameworks
directory (node_modules/electron/dist/Electron.app/Contents/Frameworks/libffmpeg.dylib
)
Ran the app again and it worked.