Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NiceGUI + 打包: 启动比较慢,如何解决? #5

Open
lightcax opened this issue Nov 7, 2023 · 1 comment
Open

NiceGUI + 打包: 启动比较慢,如何解决? #5

lightcax opened this issue Nov 7, 2023 · 1 comment
Labels
help wanted Extra attention is needed NiceGUI

Comments

@lightcax
Copy link

lightcax commented Nov 7, 2023

nicegui 打包后,启动比较慢,估计是加载本地服务器导致,是否可以优化?谢谢

@lightcax lightcax closed this as completed Nov 7, 2023
@lightcax lightcax reopened this Nov 7, 2023
@hhstore hhstore added the help wanted Extra attention is needed label Dec 19, 2023
@hhstore
Copy link
Member

hhstore commented Dec 19, 2023

  • 这个不是 nicegui 的问题.
  • 是 Python 顽疾.
  • 基于 pyinstaller 等工具打包 Python 项目成 app, 启动都很慢.
  • 即使是换别的工具, 也会有新的问题. (我 repo 里, 基本都测试了, 都不好用)

启动慢的主要原因:

  • 是打包了 Python 解释器, Python 解释器启动很慢. (类似 Java JVM 启动)
  • 打包(如果是 onefile), 本质是类似 zip, 存在解压过程.
  • 所以, 常态是 10-20s 才能打开. 这个目前是无解的.
  • 不光慢, pyinstaller 打包 nicegui (MacOS) 还会出现打开后, 疯狂创建 main 进程(bug). 原因是 pyinstaller 打包多进程项目, 有 bug. 而 nicegui 内部实现, 依赖 多进程.

绕行解决办法: (绿色模式)

  • 原理: 过去 Windows 平台, 常见的 绿色免安装软件.
  • 做法: 打包 Python 解释器 + pip 依赖包 + 源码编译结果 pyz, 一起打包发布.
  • 优点: 启动快.
  • 缺点: 每个平台, 都要打包对应平台的 Python.

可以参考:

教程:

工具:

原理:

@hhstore hhstore changed the title 启动比较慢,如何解决? NiceGUI + 打包: 启动比较慢,如何解决? Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed NiceGUI
Projects
None yet
Development

No branches or pull requests

2 participants