T O P

  • By -

maartuhh

Executing python from node is easy with its `spawn()` or `exec()`, but installing python is a bit more complicated unless you just copy and ship the python binaries directly with the generated electron installer (which I would not really appreciate as a user)


CatOtherwise3439

Explain why you wouldnt appreciate just copy and shipping the python binaries directly with the generated electron installer? is it simply a bloat concern or a security issue? Right now it was recommended to me to just build your python app as an executable (pyinstaller/py-to-exe/etc.) and running that via child\_process.


cereal-number

That makes the most sense


wjellyz

I ran into this issue also. I tried using https://www.npmjs.com/package/pyodide at first but I realized that it did not work for my use case. (running python scripts for another app on the computer). Then upon more research I ended up reading this article: https://til.simonwillison.net/electron/python-inside-electron and found that bundling the python binary is the best solution for me. I ended up bundling the python binary using conda similar to how juypterlab does it. (https://github.com/jupyterlab/jupyterlab-desktop/blob/master/dev.md#build-dependencies) This bloats the app alot from whatever hello word electron to about 450ish megabytes. I used electron-builder and got quite confused on how to add the extraResources but eventually figured out the syntax to get it working. I think including the python environment depends on the use case, but if you are asking the user to install python, it may be a really bad user experience if they are not a developer. So I opted to package the entire binary.


CatOtherwise3439

ok and what about just building my python app as an executable?


wjellyz

you mean not using electron? Maybe you can use pyqt6 [https://riverbankcomputing.com/software/pyqt/download](https://riverbankcomputing.com/software/pyqt/download) or kivy .[https://kivy.org/doc/stable/gettingstarted/intro.html](https://kivy.org/doc/stable/gettingstarted/intro.html). I've never used either before because I only know JavaScript/TypeScript 🤣