How can I distribute an Electron app with Python

Viewed 1085

I have a Python web application that I want to wrap in Electron. The web application backend is a very slim Flask app that forwarded calls to a Python package that does the processing, and formats the results. We have a React frontend that talks to this backend. We also have a pip based installation, that runs the Flask backend and serves the frontend, so you can pip install run the server and use it from your browser. This is similar to how Pgadmin 4 works.

Since this application is only used by people on their own computers, and never installed on a server, I want to convert it into an Electron app. However, I couldn't figure out how to distribute this application in one setup for Windows, MacOS and Linux. I don't want the users to have to install Python on their computers.

How can I do that?

2 Answers

There is a couple of clues on how to do that, even though I'm still unsure whether all necessary python modules can be bundled easily.

I have a similar case, even though I just want to bundle a prototype in an electron application so I can send it to collaborators for evaluation, without any intent of shipping it to final users.

My list of hints:

I really don't see why you need to throw electron in the mix, instead of just using your browser. I reckon that a barebone electron app that serves your page in a single window is going to be 50Mb. The key benefits of electron is that it lets you do system calls (access local files / devices), but if you are running flask you already have this ability.

Your main obstacle is how to distribute the flask app, specifically without installing python - and electron is not going to make things any easier to that respect. You should probably look at pyinstaller which lets you create executables that embed python.

Now, if you're talking of getting rid of python altogether, then indeed you could do that, nodejs has a rich set of libraries for everything os / db-related, even image processing, but it will lack in data science and processing. YMMV.

Related