Files
kman/打包MacBook指南.md
2025-09-18 17:02:40 +08:00

44 lines
901 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# MacBook 打包 PySide6 应用指南
## 1. 安装 PyInstaller
```zsh
pip install pyinstaller
```
## 2. 打包命令(推荐单文件)
```zsh
pyinstaller --noconfirm --windowed --onefile --icon=icons/Cbb20.png kmanapp.py
```
- `--windowed`无控制台窗口GUI应用必选
- `--onefile`:生成单一可执行文件
- `--icon=...`:指定应用图标
## 3. 资源文件处理
如有图片、qrc、数据库等资源需在 `kmanapp.spec``datas` 字段添加:
```python
# 在 .spec 文件的 a = Analysis(...) 里 datas= 加入:
('icons/Cbb20.png', 'icons'),
('kmanapp.qrc', '.'),
('kmanapp_rc.py', '.'),
('vocab.db', '.'),
# 其他资源...
```
## 4. 重新打包
```zsh
pyinstaller kmanapp.spec
```
## 5. 运行
打包后在 `dist/` 目录下生成可执行文件,双击即可运行。
---
如需自动化脚本或遇到打包报错,请告知具体需求。