-1

I recently finished a project I have been working on for a while. I should present my work on the class' smart board which runs on linux. Taking in mind i can't download its modules because i don't have sudo permission nor it does have internet. So to get around this I decided to build it using pyinstaller. Everything seemed to work just fine in my device, but when i double checked in Virtual box this error pops up.

Traceback (most recent call last):
  File "main.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller/loader/pyimod03_importers.py", line 540, in exec_module
  File "matplotlib/__init__.py", line 923, in <module>
  File "matplotlib/__init__.py", line 608, in matplotlib_fname
RuntimeError: Could not find matplotlibrc file; your Matplotlib install is broken
[8025] Failed to execute script main

So how can i build it so it works for all devices without the need of installation for any modules

loser404
  • 3
  • 2
  • Presumably `matplotlib/__init__.py", line 608` is attempting to open a file which isn’t bundled into your exe. Try examining that code to find out where it’s looking? Given you have the source of matplotlib you may be able to temporarily add some debugging printout to make it clear which file and which folder it’s assuming? Then see if you can explicitly add this file to your pyinstaller build see the documentation https://pyinstaller.readthedocs.io/en/stable/spec-files.html#adding-files-to-the-bundle – DisappointedByUnaccountableMod Jul 10 '21 at 21:26
  • Or, just a little bit of searching for _pyinstaller error matplotlibrc_ finds this https://stackoverflow.com/questions/62701684/python-pyinstaller-matplotlibrc#62713648. NOTE you are of course free to do some more searching along the same lines. – DisappointedByUnaccountableMod Jul 10 '21 at 21:30
  • If you use that answer don’t forget to upvote it. – DisappointedByUnaccountableMod Jul 10 '21 at 21:34

1 Answers1

0

matplotlib requires a config file names matplotlibrc to be found in one of 4 specific locations, the first one being the courant directory (see https://matplotlib.org/tutorials/introductory/customizing.html#the-matplotlibrc-file) One this file prepared as per need it can be embeeded in the exe by adding --add-data=matplotlibrc;. to the build command (replace ; with : for non-Windows systems)