Skip to content

python 3.8.10

Python's ease of learning, powerful capabilities, and wide range of applications have made this language widely used. This document will introduce how to integrate a Python project into a desktop application.

Preparation

  1. Download the project
bash
# gitee
git clone https://gitee.com/dromara/electron-egg.git

# github
git clone https://github.com/dromara/electron-egg.git
  1. Switch to the demo branch
bash
git checkout -b demo-python remotes/origin/demo
  1. Install frontend, Electron, and Python dependencies
bash
# Install Electron dependencies in the root directory
npm i

# Enter the frontend directory and install dependencies
cd ./frontend 
npm i

# Install Python dependencies
cd ./python
pip install -r requirements.txt

Build Python Program

Note: When using conda, be aware of the following

You need to configure the Python location in bin.js based on the result returned by where python, and cx_Freeze should be installed using conda install -c conda-forge cx_freeze

bash
# Install cx_Freeze, which can generate executable programs
pip install cx_Freeze

# Build Python program
npm run build-python

Run

bash
npm run start

Check the cross menu in the demo for the Python service.