打包matplotlib出现RuntimeError: Could not find the matplotlib data files

在用pyinstaller打包exe时,出现

pyimod03_importers.py:493: 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.
  exec(bytecode, module.__dict__)
Traceback (most recent call last):
  File "test_Drawing_day.py", line 10, in <module>
    import matplotlib.pyplot as plt
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "d:\anaconda\envs\python36_32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "matplotlib\__init__.py", line 898, in <module>
  File "matplotlib\cbook\__init__.py", line 480, in _get_data_path
  File "matplotlib\__init__.py", line 239, in wrapper
  File "matplotlib\__init__.py", line 534, in get_data_path
  File "matplotlib\__init__.py", line 239, in wrapper
  File "matplotlib\__init__.py", line 566, in _get_data_path
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.

ok,matplotlib3.2以后就把mpl-data分离出去了,我查看了下自己的matplotlib版本

(python36_32) D:\Anaconda\envs\python36_32\Scripts>pip list
Package           Version
----------------- -------------------
altgraph          0.17
astroid           2.4.0
certifi           2020.4.5.1
chardet           3.0.4
click             7.1.2
colorama          0.4.3
comtypes          1.1.7
cssselect         1.1.0
cycler            0.10.0
easytrader        0.21.0
easyutils         0.1.7
Flask             1.1.2
future            0.18.2
get               0.0.0
idna              2.10
isort             4.3.21
itsdangerous      1.1.0
Jinja2            2.11.2
joblib            0.15.1
kiwisolver        1.2.0
lazy-object-proxy 1.4.3
lxml              4.5.1
MarkupSafe        1.1.1
matplotlib        3.3.0  ##这里

行,卸载,重装(在anaconda prompt里)

pip uninstall matplotlib
pip install matplotlib==3.1.1

ok,安装好新的版本之后重新打包

pyinstaller -F XXX.py

找到.spec文件
修改 hiddenimports=[‘matplotlib’],
在这里插入图片描述
再继续执行

pyinstaller -F XXX.spec

ok,打包完毕
执行时,会出现warning,但是不影响结果~
bingo~ 希望对你有帮助,我弄了几个小时了,大哭!!!

  • 13
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 12
    评论
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值