Skip to content

python 3.8.10

python 的易学性、强大的功能和广泛的应用场景,让这门语言被广泛使用,该文档会介绍如何把python项目集成到桌面端。

准备

  1. 下载项目
bash
# gitee
git clone https://gitee.com/dromara/electron-egg.git

# github
git clone https://github.com/dromara/electron-egg.git
  1. 切换 demo 分支
bash
git checkout -b demo-python remotes/origin/demo
  1. 安装 前端electronpython 依赖
bash
# 根目录安装electron依赖
npm i

# 进入前端目录安装依赖
cd ./frontend 
npm i

# 安装python依赖
cd ./python
pip install -r requirements.txt

构建python程序

注:使用 conda 时要注意

要在bin.js里根据 where python 返回的结果去配置python位置,而且cx_Freeze要用conda install -c conda-forge cx_freeze方式安装

bash
# 安装 cx_Freeze,它可以生成可执行程序
pip install cx_Freeze

# 构建python程序
npm run build-python

运行

bash
npm run start

查看demo的cross菜单,Python服务。