一、python 打包exe出现RuntimeError: Could not find the matplotlib data files 的解决方法
在打包包含matplotlib库时出现RuntimeError: Could not find the matplotlib data files的解决方法。
错误提示里面的介绍:
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.
第一步:卸载,重装(在anaconda prompt里)或者虚拟环境下,看你在哪里打包,就在哪里装
pip uninstall matplotlib
pip install matplotlib==3.1.1
第二步:打包
pyinstaller -F -w -i ./img/icon.ico main_eletric.py
第三步:修改spec文件
原hiddenimports=[],
修改后
hiddenimports=[‘matplotlib’],
二、pkg_resources.DistributionNotFound: The 'msoffcrypto-tool’ distribution was not found and is required by the application
添加hook-ctypes.macholib.py文件,文件内容如下:
from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata('msoffcrypto-tool')
添加hook-ctypes.macholib.py 后进行打包,命令如下
pyinstaller -F -w -i ./icon.ico main_eletric.py --additional-hooks-dir=.
.spec文件如下:
原文链接:https://blog.youkuaiyun.com/kobeyu652453/article/details/108871179