pyinstaller -w xxxx打包完成后,双击xxx.exe,惊现下图:
1. 查看报错信息
用 pyinstaller -F XXX.py 指令再次生成.exe文件(带命令窗口),再双击打开.exe文件,命令窗口含报错信息,但一闪即逝。为查看报错信息,可在cmd窗口中,拖入exe文件,然后回车,显示如下图错误。
其中显示:
MatplotlibDeprecationWarning: Matplotlib installs where the data is
not in the mpl-data subdirectory of the package are deprecated since
3.2 and support for them will be removed two minor releases later.
2. 降低matplotlib版本
利用conda list
查看自己安装的matplot版本为3.3.2,高于3.2,因此尝试降级版本。
重新安装3.1.2版本:
3. 重新打包
重新打包,运行exe,再次报错:
洗洗睡吧
最终解决方法:
新建新环境
安装Python版本3.6.0,并安装其余程序所需库。
最后再用pyinstaller打包。
具体方法详见https://blog.csdn.net/weixin_46604505/article/details/117811089?spm=1001.2014.3001.5501
总结: 主要是因为打包时候有关库与pyinstaller不兼容导致打包失败,因此修改相关版本即可。本次尝试降级Python到3.6恰好成功打包了,其他类似问题也可尝试修改版本,最重要的是在新环境中修改版本,以免互相影响。