pyinstaller打包之后运行出现:Could not find the matplotlib data files
Posted Data+Science+Insight
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pyinstaller打包之后运行出现:Could not find the matplotlib data files相关的知识,希望对你有一定的参考价值。
pyinstaller 打包之后Could not find the matplotlib data files
目录
pyinstaller 打包之后Could not find the matplotlib data files
笔者使用的python版本为3.8.5
pyinstaller版本为4.3
matplotlib版本为4.3
问题
Runtime Error Could not find the matplotlib data files
常见解决方案
许多网络上的解决方案如下: 就是降低matplotblib的版本,笔者原本matplotlib的版本为4.3
pip install matplotlib==3.0.3
pip install matplotlib==3.1.3
笔者同事降低为3.0.3错误依旧;
降低为3.1.3成功
其他解决方案
找到你的python安装的pyinstaller的hooks文件夹中的hook-matplotlib.py文件:
修改文件中文本旧有内容:
datas = [ (mpl_data_dir, "mpl-data"), ]
改为:
datas = [ (mpl_data_dir, "matplotlib/mpl-data"), ]
# 使用UE或者文本编辑器打开hook-matplotlib.py文件
# 内容如下,修改之后保存即可;
#-----------------------------------------------------------------------------
# Copyright (c) 2013-2019, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks import exec_statement
mpl_data_dir = exec_statement(
"import matplotlib; print(matplotlib._get_data_path())")
datas = [
(mpl_data_dir, "mpl-data"),
]
Find and edit the hook-matplotlib.py inside of lib/site-packages/pyinstaller/hooks
edit the data section from: datas = [ (mpl_data_dir, "mpl-data"), ]
to
datas = [ (mpl_data_dir, "matplotlib/mpl-data"), ]
参考:Could not find the matplotlib data files
参考:matplotlib: RuntimeError: Could not find the matplotlib data files #393
以上是关于pyinstaller打包之后运行出现:Could not find the matplotlib data files的主要内容,如果未能解决你的问题,请参考以下文章