Search code examples
pythonpyqt5matplotlib-widget

After I convert my script to executable file, it gives this error : MatplotlibDeprecationWarning


I have an error which's complete form is

MatplotlibDeprecationWarning: The MATPLOTLIBDATA environment variable was deprecated in Matplotlib 3.1 and will be removed in 3.3

I converted my script into executable file. After conversion, it never opened. When I execute script with IDEs(VS Code, Linux shell, and Spyder), it works. Somehow it does not open after I converted it to exe. I wrote some lines to avoid from this error, but simply it did not work. For example; Python/matplotlib : getting rid of matplotlib.mpl warning

I used pyinstaller and auto-py-to-exe to convert my script into exe.

This is the beginning of my code:

from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt, QDate, pyqtSlot
from PyQt5.QtGui import QIcon
from datetime import datetime
import calendar
import sys
import numpy as np 
import pandas as pd
from scipy.signal import find_peaks
import os
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas, NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
import matplotlib.dates as mdates
matplotlib.use('Qt5Agg')
myFmt = mdates.DateFormatter('%d')

It is very long to put all the code here. Thank you very much for your interest.


Solution

  • Arda, I've found out after trial and error that pyinstaller has a conflict with the latest version of matplotlib. In order to produce an executable of your script with pyinstaller you should downgrade matplotlib to 3.2.2 version. I have also found some problems with the latest (1.19.4) version of numpy which went away when I downgraded numpy to 1.19.3.

    You can check my repository https://github.com/matiasleoni/COVID19_plotter where I created a simple script to plot COVID19 global data using matplotlib package. After many failed attempts I was also able to create an executable version of it as I described above (see also the README.md of that repository).