5

Pyinstaller 打包无头浏览器,弹出 cmd 窗口的问题

 1 year ago
source link: https://www.v2ex.com/t/884875
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Python

Pyinstaller 打包无头浏览器,弹出 cmd 窗口的问题

  Juszoe · 3 小时 30 分钟前 · 304 次点击

用 PyQt(PySide)和 Playwright(无头浏览器)写了个小软件,headless 也设置成True了,直接用 python 运行是不会弹出任何额外的 cmd 窗口的。

但是当我用如下命令打包:

pyinstaller -F -w ui.py --key xxxxx --hidden-import "PySide6.QtGui" -i asset/favicon.ico

实际效果:主程序的 cmd 窗口是没有了,但是每启动一个无头浏览器,会弹出一个 cmd 窗口(没有任何内容)。

初步猜测是因为启动了一个浏览器进程,所以 pyinstaller 没有 hook 住,查到文档说要在主程序开始前调用multiprocessing.freeze_support(),但我尝试过也没有效果。

请问各位大佬们有遇到过类似的问题吗?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK