Executable Fails at Runtime - RuntimeError: Could not find the matplotlib data files

105 views
Skip to first unread message

Sandipan Gangopadhyay

unread,
Jul 28, 2020, 1:26:28 PM7/28/20
to PyInstaller
This only happens with Python 64bit (3.8.3)
Was working fine on Python 32bit (3.8.3)

Python code where error is happening:

from moviepy.editor import *
from moviepy.video.io.VideoFileClip import VideoFileClip
from moviepy.video.io.preview import preview
from moviepy.video.fx.resize import resize
from moviepy.video.fx.fadein import fadein
from moviepy.audio.fx.audio_fadein import audio_fadein

I have also tried this command:

os.environ['MATPLOTLIBDATA'] = 'C:\\Program Files\\Python38\\Lib\\site-packages\\matplotlib\\mpl-data\\' # https://stackoverflow.com/questions/63103147/could-not-find-the-matplotlib-data-files

Stack trace on PyInstaller - is successful:

pyinstaller -F -i icon2_5oT_icon.ico "Image Viewer v108.py"
208 INFO: PyInstaller: 3.6
208 INFO: Python: 3.8.3
209 INFO: Platform: Windows-10-10.0.18362-SP0
211 INFO: wrote C:\Users\Sandipan\Dropbox (Sandipan.com)\Development\Picture Viewer\Image Viewer v108.spec
214 INFO: UPX is not available.
218 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Sandipan\\Development\\Picture Viewer',
 'C:\\Users\\Sandipan\\Development\\Picture Viewer']
219 INFO: checking Analysis
827 INFO: checking PYZ
954 INFO: checking PKG
1096 INFO: Building because C:\Users\Sandipan\\Development\Picture Viewer\build\Image Viewer v108\Image Viewer v108.exe.manifest changed
1096 INFO: Building PKG (CArchive) PKG-00.pkg
83974 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
86023 INFO: Bootloader c:\program files\python38\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
86026 INFO: checking EXE
86060 INFO: Rebuilding EXE-00.toc because pkg is more recent
86061 INFO: Building EXE from EXE-00.toc
86076 INFO: Copying icons from ['icon2_5oT_icon.ico']
86082 INFO: Writing RT_GROUP_ICON 0 resource with 76 bytes
86082 INFO: Writing RT_ICON 1 resource with 1128 bytes
86082 INFO: Writing RT_ICON 2 resource with 2440 bytes
86083 INFO: Writing RT_ICON 3 resource with 4264 bytes
86083 INFO: Writing RT_ICON 4 resource with 9640 bytes
86083 INFO: Writing RT_ICON 5 resource with 28485 bytes
86095 INFO: Updating manifest in C:\Users\Sandipan\Development\Picture Viewer\build\Image Viewer v108\run.exe.7duzm7h4
86097 INFO: Updating resource type 24 name 1 language 0
86108 INFO: Appending archive to EXE C:\Users\Sandipan\Development\Picture Viewer\dist\Image Viewer v108.exe
86393 INFO: Building EXE from EXE-00.toc completed successfully.

Stack trace when executable fails:

C:\Users\Sandipan\OneDrive\Desktop>"image viewer v108.exe"
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "Image Viewer V108.py", line 183, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\program files\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\moviepy\editor.py", line 60, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\program files\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\moviepy\video\io\sliders.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\program files\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\matplotlib\__init__.py", line 898, in <module>
  File "site-packages\matplotlib\cbook\__init__.py", line 480, in _get_data_path
  File "site-packages\matplotlib\__init__.py", line 239, in wrapper
  File "site-packages\matplotlib\__init__.py", line 534, in get_data_path
  File "site-packages\matplotlib\__init__.py", line 239, in wrapper
  File "site-packages\matplotlib\__init__.py", line 566, in _get_data_path
RuntimeError: Could not find the matplotlib data files
[19204] Failed to execute script Image Viewer V108

Is there a way to package the data files in the executable? Additional complexity that I am not using matplotlib myself ... moviepy is and that is not my code! :(

Thanks for any help.

Regards,

Sandipan

bwoodsend

unread,
Jul 31, 2020, 8:09:15 AM7/31/20
to PyInstaller

This is issue #5004. We’re midway through fixing it. For now just pip install matplotlib==3.2.2.

Sandipan Gangopadhyay

unread,
Jul 31, 2020, 8:31:50 AM7/31/20
to PyInstaller
Thanks so much. 
This effectively downgrades my matplotlib from 3.3.0 to 3.2.2
I hope that does not impact other modules like tensorflow, etc.
Appreciate the help and looking forward to the long term solution.
Thanks.
Reply all
Reply to author
Forward
0 new messages