8

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
  • 4
    We're mid way through fixing this (see here). For now please pip install "matplotlib<3.3". Commented Jul 28, 2020 at 20:19

5 Answers 5

6

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

Sign up to request clarification or add additional context in comments.

Comments

4

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.

Comments

3

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

Comments

1

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

1 Comment

My freshly installed pyinstaller already has "matplotlib/mpl-data" but I'm still getting an error
0

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'

2 Comments

Thank you for your response, but this did not fix my problem.
The MATPLOTLIBDATA variable is no longer supported and trying to use it breaks matplotlib. In fact this is partly why it no longer works on PyInstaller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.