安装
pip3 install pyinstaller
然后在 terminal 中 cd 到项目路径,
运行程序入口,也就是main函数所在文件 main.py
在项目所在工作路径输入命令:
sudo pyinstaller --windowed --onefile --clean --noconfirm main.py
sudo pyinstaller --clean --noconfirm --windowed --onefile main.spec
sudo 获取权限,可能要求输入密码
如果想要打出来的包有图标第一条命了替换:
pyinstaller --windowed --onefile --icon=sat_tool_icon.icns --clean --noconfirm main.py
一般很少一次通过,主要是一些包导入问题和项目文件配置路径
我遇到问题时找不到项目的配置文件
获取包路径的父路径,不可将路径写成绝对路径
os.path.dirname(sys.argv[0])
打出来的包是:
点击wx_main时候 我遇到了 This program needs access to the screen. Please run with a
Framework build of python, and only when you are logged in
on the main display of your Mac.没找到好的解决方法,然后采用点击包里面的可执行文件显示的,具体操作如下:
显示wx_main_file包内容,会看到MacOS文件,我将配置文件放入
然后点击wx_main运行,终端可以看到打印的日志信息
由于是一个小工具就没有打包成 .dmg文件