【打包】pyinstaller打包matplotlib后闪退的实操可行的解决方法

PY的编程内容

import os
import tempfile
os.environ[‘MPLCONFIGDIR’]=tempfile.mkdtemp()
来源:大概意思:电脑上少一个缓存的地方,所以要通过import加在了源码的py文件中了。

打包准备

推荐在虚拟环境中,将pyinstaller和matplotlib分别调级:
PyInstaller 3.6

python -m pip install pyinstaller == 3.6

matplotlib 3.2.2

python -m pip install matplotlib == 3.2.2

打包程序

pyinstaller -F -w D:\待打包的matplotlib.py

参考成品

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Allan_lam/article/details/135458485