Mihai Plesa
Mihai Plesa

Reputation: 141

Could not find the matplotlib data files

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.

Upvotes: 8

Views: 8811

Answers (5)

Leonardo Wolter
Leonardo Wolter

Reputation: 149

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

Upvotes: 1

bertha
bertha

Reputation: 123

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

Upvotes: 3

apemanx
apemanx

Reputation: 43

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.

Upvotes: 4

Mihai Plesa
Mihai Plesa

Reputation: 141

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

Upvotes: 6

HumayunM
HumayunM

Reputation: 554

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'

Upvotes: 0

Related Questions