Could not find the matplotlib data files

蓝咒 提交于 2021-01-02 06:12:58

问题


I am new to python and I am trying to create an .exe from py script with pyinstaller but I get this error when trying to run the .exe: Could not find the matplotlib data files. When i run the script in python idle i dont get this error.

I've tried:

 import matplotlib
   setup(
        data_files=matplotlib.get_py2exe_datafiles(),
   )

But i get an error saying that setup is not defined.


回答1:


I've fixed the problem by downgrading matplotlib to version 3.0.3 Using this command: python -m pip install matplotlib==3.0.3




回答2:


hi i faced the same problem too when generating script using pyinstaller (im using python 3.7). The problem is solved when i installed:

pip install matplotlib==3.0.3




回答3:


The only thing that worked "sustainably" for me is to also downgrade to and earlier version of Matplotlib version 3.1.3. I can now use pyinstaller. I can also run all program without that horrible warnings and stuff that it gives.

I used pip install matplotlib==3.1.3. make sure you uninstall all previous matplotlib.




回答4:


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"), ]




回答5:


Pyinstaller can't find the location of your mpl-data folder. Please search for mpl-data directroy and export that in your program

as a workaround

import os
os.environ['MATPLOTLIBDATA'] = 'location of mpl-data folder'


来源:https://stackoverflow.com/questions/63103147/could-not-find-the-matplotlib-data-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!