I try to plot some dataframe with matplotlib in a GUI designed by pyqt5. I 
use pyinstaller for packaging as following:

pyinstaller main.py

and its outcome:

> 33 INFO: PyInstaller: 3.4
>
> 34 INFO: Python: 3.6.9
>
> 34 INFO: Platform: Linux-5.4.0-42-generic-x86_64-with-Ubuntu-18.04-bionic
>
> 35 INFO: wrote 
> /home/shahriar/python_projects/first_test/src/main/python/main.spec
>
> 36 INFO: UPX is not available.
>
> 37 INFO: Extending PYTHONPATH with paths
>
> ['/home/shahriar/python_projects/first_test/src/main/python',
>
> '/home/shahriar/python_projects/first_test/src/main/python']
>
> 38 INFO: checking Analysis
>
> 58 INFO: Building because 
> /home/shahriar/python_projects/first_test/src/main/python/main.py changed
>
> 59 INFO: Initializing module dependency graph...
>
> 60 INFO: Initializing module graph hooks...
>
> 61 INFO: Analyzing base_library.zip ...
>
> 2440 INFO: running Analysis Analysis-00.toc
>
> 2485 INFO: Caching module hooks...
>
> 2490 INFO: Analyzing 
> /home/shahriar/python_projects/first_test/src/main/python/main.py
>
> 3151 INFO: Processing pre-find module path hook distutils
>
> 3996 INFO: Processing pre-safe import module hook 
> setuptools.extern.six.moves
>
> 4263 INFO: Processing pre-find module path hook site
>
> 4263 INFO: site: retargeting to fake-dir 
> '/home/shahriar/first_test/lib/python3.6/site-packages/PyInstaller/fake-modules'
>
> 8256 INFO: Processing pre-safe import module hook six.moves
>
> 22239 INFO: Loading module hooks...
>
> 22239 INFO: Loading module hook "hook-sqlite3.py"...
>
> 22285 INFO: Loading module hook "hook-scipy.py"...
>
> 22286 INFO: Loading module hook "hook-distutils.py"...
>
> 22286 INFO: Loading module hook "hook-scipy.sparse.csgraph.py"...
>
> 22289 INFO: Loading module hook "hook-scipy.linalg.py"...
>
> 22290 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
>
> 22385 INFO: Loading module hook "hook-PyQt5.py"...
>
> 22400 INFO: Loading module hook "hook-numpy.core.py"...
>
> 22529 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
>
> 22555 INFO: Loading module hook "hook-encodings.py"...
>
> 22607 INFO: Loading module hook "hook-matplotlib.py"...
>
> 22878 INFO: Loading module hook "hook-PIL.Image.py"...
>
> 23238 INFO: Loading module hook "hook-pycparser.py"...
>
> 23239 INFO: Loading module hook "hook-lib2to3.py"...
>
> 23240 INFO: Loading module hook "hook-sysconfig.py"...
>
> 23245 INFO: Loading module hook "hook-numpy.py"...
>
> 23246 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
>
> 23246 INFO: Loading module hook "hook-pkg_resources.py"...
>
> 23589 INFO: Processing pre-safe import module hook win32com
>
> 23631 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
>
> 23702 INFO: Loading module hook "hook-pytz.py"...
>
> 23722 INFO: Loading module hook "hook-scipy.special._ufuncs.py"...
>
> 23722 INFO: Loading module hook "hook-pydoc.py"...
>
> 23723 INFO: Loading module hook "hook-_tkinter.py"...
>
> 23804 INFO: checking Tree
>
> 23808 INFO: checking Tree
>
> 23809 INFO: Loading module hook "hook-setuptools.py"...
>
> /home/shahriar/first_test/lib/python3.6/site-packages/setuptools/distutils_patch.py:26:
>  
> UserWarning: Distutils was imported before Setuptools. This usage is 
> discouraged and may exhibit undesirable behaviors or errors. Please use 
> Setuptools' objects directly or at least import Setuptools first.
>
> "Distutils was imported before Setuptools. This usage is discouraged "
>
> 24243 INFO: Loading module hook "hook-scipy.special._ellip_harm_2.py"...
>
> 24244 INFO: Loading module hook "hook-matplotlib.backends.py"...
>
> 24998 INFO: Matplotlib backend "GTK3Agg": ignored
>
> The GTK3 backends require PyGObject
>
> 25466 INFO: Matplotlib backend "GTK3Cairo": ignored
>
> The GTK3 backends require PyGObject
>
> 25726 INFO: Matplotlib backend "MacOSX": ignored
>
> cannot import name '_macosx'
>
> 25991 INFO: Matplotlib backend "nbAgg": ignored
>
> No module named 'IPython'
>
> -c:12: MatplotlibDeprecationWarning:
>
> The matplotlib.backends.backend_qt4agg backend was deprecated in 
> Matplotlib 3.3 and will be removed two minor releases later.
>
> 26478 INFO: Matplotlib backend "Qt4Agg": added
>
> -c:12: MatplotlibDeprecationWarning:
>
> The matplotlib.backends.backend_qt4cairo backend was deprecated in 
> Matplotlib 3.3 and will be removed two minor releases later.
>
> 27028 INFO: Matplotlib backend "Qt4Cairo": added
>
> 27514 INFO: Matplotlib backend "Qt5Agg": added
>
> 28063 INFO: Matplotlib backend "Qt5Cairo": added
>
> 28495 INFO: Matplotlib backend "TkAgg": added
>
> 28964 INFO: Matplotlib backend "TkCairo": added
>
> 29231 INFO: Matplotlib backend "WebAgg": ignored
>
> Traceback (most recent call last):
>
> File 
> "/home/shahriar/first_test/lib/python3.6/site-packages/matplotlib/backends/backend_webagg.py",
>  
> line 27, in
>
> import tornado
>
> ModuleNotFoundError: No module named 'tornado'
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>
> File "", line 12, in
>
> File 
> "/home/shahriar/first_test/lib/python3.6/site-packages/matplotlib/backends/backend_webagg.py",
>  
> line 29, in
>
> raise RuntimeError("The WebAgg backend requires Tornado.") from err
>
> RuntimeError: The WebAgg backend requires Tornado.
>
> 29649 INFO: Matplotlib backend "WX": ignored
>
> No module named 'wx'
>
> 29910 INFO: Matplotlib backend "WXAgg": ignored
>
> No module named 'wx'
>
> 30179 INFO: Matplotlib backend "WXCairo": ignored
>
> No module named 'wx'
>
> 30505 INFO: Matplotlib backend "agg": added
>
> 30868 INFO: Matplotlib backend "cairo": added
>
> 31301 INFO: Matplotlib backend "pdf": added
>
> 31727 INFO: Matplotlib backend "pgf": added
>
> 32083 INFO: Matplotlib backend "ps": added
>
> 32430 INFO: Matplotlib backend "svg": added
>
> 32847 INFO: Matplotlib backend "template": added
>
> 33202 INFO: Loading module hook "hook-PIL.py"...
>
> 33205 INFO: Excluding import 'PyQt4'
>
> 33207 INFO: Excluding import 'tkinter'
>
> 33210 INFO: Removing import of tkinter from module PIL.ImageTk
>
> 33211 INFO: Excluding import 'PySide'
>
> 33214 INFO: Import to be excluded not found: 'FixTk'
>
> 33215 INFO: Excluding import 'PyQt5'
>
> 33217 INFO: Removing import of PyQt5.QtCore from module PIL.ImageQt
>
> 33217 INFO: Removing import of PyQt5.QtGui from module PIL.ImageQt
>
> 33217 INFO: Loading module hook "hook-xml.py"...
>
> 33261 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
>
> 33263 INFO: Import to be excluded not found: 'FixTk'
>
> 33263 INFO: Excluding import 'tkinter'
>
> 33264 INFO: Loading module hook "hook-pandas.py"...
>
> 33994 INFO: Looking for ctypes DLLs
>
> 34103 WARNING: library user32 required via ctypes not found
>
> 34214 WARNING: library msvcrt required via ctypes not found
>
> 34235 INFO: Analyzing run-time hooks ...
>
> 34249 INFO: Including run-time hook 'pyi_rth_pkgres.py'
>
> 34250 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
>
> 34253 INFO: Including run-time hook 'pyi_rth__tkinter.py'
>
> 34254 INFO: Including run-time hook 'pyi_rth_mplconfig.py'
>
> 34255 INFO: Including run-time hook 'pyi_rth_mpldata.py'
>
> 34256 INFO: Including run-time hook 'pyi_rth_qt5.py'
>
> 34284 INFO: Looking for dynamic libraries
>
> 37779 INFO: Looking for eggs
>
> 37780 INFO: Python library not in binary dependencies. Doing additional 
> searching...
>
> 37800 INFO: Using Python library 
> /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0
>
> 37826 INFO: Warnings written to 
> /home/shahriar/python_projects/first_test/src/main/python/build/main/warn-main.txt
>
> 37958 INFO: Graph cross-reference written to 
> /home/shahriar/python_projects/first_test/src/main/python/build/main/xref-main.html
>
> 38033 INFO: checking PYZ
>
> 38046 INFO: Building because toc changed
>
> 38047 INFO: Building PYZ (ZlibArchive) 
> /home/shahriar/python_projects/first_test/src/main/python/build/main/PYZ-00.pyz
>
> 40255 INFO: Building PYZ (ZlibArchive) 
> /home/shahriar/python_projects/first_test/src/main/python/build/main/PYZ-00.pyz
>  
> completed successfully.
>
> 40295 INFO: checking PKG
>
> 40296 INFO: Building because toc changed
>
> 40296 INFO: Building PKG (CArchive) PKG-00.pkg
>
> 40460 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
>
> 40462 INFO: Bootloader 
> /home/shahriar/first_test/lib/python3.6/site-packages/PyInstaller/bootloader/Linux-64bit/run
>
> 40462 INFO: checking EXE
>
> 40464 INFO: Building because toc changed
>
> 40464 INFO: Building EXE from EXE-00.toc
>
> 40466 INFO: Appending archive to ELF section in EXE 
> /home/shahriar/python_projects/first_test/src/main/python/build/main/main
>
> 40659 INFO: Building EXE from EXE-00.toc completed successfully.
>
> 40665 INFO: checking COLLECT
>
> WARNING: The output directory 
> "/home/shahriar/python_projects/first_test/src/main/python/dist/main" and 
> ALL ITS CONTENTS will be REMOVED! Continue? (y/n)y
>
> 110470 INFO: Removing dir 
> /home/shahriar/python_projects/first_test/src/main/python/dist/main
>
> 110556 INFO: Building COLLECT COLLECT-00.toc
>
> 111044 INFO: Building COLLECT COLLECT-00.toc completed successfully.
>

when I run the executable file as ./dist/main, I get this error:

/home/shahriar/first_test/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py:627:
 
> MatplotlibDeprecationWarning: Matplotlib installs where the data is not in 
> the mpl-data subdirectory of the package are deprecated since 3.2 and 
> support for them will be removed two minor releases later.
> exec(bytecode, module.dict)
> Traceback (most recent call last):
> File "main.py", line 20, in
> from matplotlib import ticker
> File "", line 971, in _find_and_load
> File "", line 955, in _find_and_load_unlocked
> File "", line 665, in _load_unlocked
> File 
> "/home/shahriar/first_test/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py",
>  
> line 627, in exec_module
> exec(bytecode, module.dict)
> File "matplotlib/init.py", line 898, in
> File "matplotlib/cbook/init.py", line 480, in _get_data_path
> File "matplotlib/init.py", line 239, in wrapper
> File "matplotlib/init.py", line 534, in get_data_path
> File "matplotlib/init.py", line 239, in wrapper
> File "matplotlib/init.py", line 563, in _get_data_path
> NameError: name 'defaultParams' is not defined
> [24669] Failed to execute script main 


I also got mpl-data directory with

sudo find -name "mpl-data"

I took the one which was in the directory of my project:

./python_projects/first_test/target/PlottingTest/mpl-data

And imported it in my python file (main.py) as following:

import os
os.environ['MATPLOTLIBDATA'] = 
'./python_projects/first_test/target/PlottingTest/mpl-data'

But, it produces that error again!

Any ideas how to solve it?



   - 
   
   PyInstaller: 3.4 34 
   - 
   
   Python: 3.6.9
   - Operating system: ubuntu 18.04
   - Matplotlib version: 3.3.0
   - Matplotlib backend (print(matplotlib.get_backend())):Backend Qt5Agg is 
   interactive backend. Turning interactive mode on. Qt5Agg
   - Python version:3.6.9
   - Jupyter version (if applicable):
   - Other libraries: pyqt5, pandas

 

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/0df8d529-4ba3-403e-b6e8-bdcbb904a0cco%40googlegroups.com.

Reply via email to