打包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 "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", 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’],
打包matplotlib出现RuntimeError: Could not find the matplotlib data files_第1张图片
再继续执行

pyinstaller -F XXX.spec

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

你可能感兴趣的:(matplotlib,pywinauto)