"UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure." Is Displayed When Quantizing an Object Detection Network
Symptom
When an object detection network is quantized, the "UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure." message is displayed. As a result, the quantized detection result is not displayed on the GUI.
Possible Cause
The possible cause is that the Tkinter is not installed. You can run the following command in the Python terminal to verify the installation. If the following information is displayed, the Tkinter is not installed successfully.
hisisoc@ubuntu62:~$ python3.7.5 Python 3.7.5 (default, Mar 3 2020, 13:58:02) [GCC 7.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/python3.7.5/lib/python3.7/tkinter/__init__.py", line 36, in <module> import _tkinter # If this fails your Python may not be configured for Tk ModuleNotFoundError: No module named '_tkinter'
Solution
If the Tkinter fails to be installed by installing python3-tk, the possible cause is that multiple Python 3 versions are installed or the tk-dev library fails to be installed. If the tk-dev library fails to be installed, perform the following steps:
- Run the following command to reinstall the tk-dev library:
sudo apt-get install tk-dev
- Go to the Python 3.7.5 installation directory and recompile and install Python 3.7.5.
cd Python-3.7.5 ./configure --prefix=/usr/local/python3.7.5 --enable-shared make sudo make install
- Delete the original soft links.
sudo rm -rf /usr/bin/python3.7.5 sudo rm -rf /usr/bin/pip3.7.5 sudo rm -rf /usr/bin/python3.7 sudo rm -rf /usr/bin/pip3.7
- Set the soft links again.
sudo ln -s /usr/local/python3.7.5/bin/python3 /usr/bin/python3.7.5 sudo ln -s /usr/local/python3.7.5/bin/pip3 /usr/bin/pip3.7.5 sudo ln -s /usr/local/python3.7.5/bin/python3 /usr/bin/python3.7 sudo ln -s /usr/local/python3.7.5/bin/pip3 /usr/bin/pip3.7
- Verify the installation again. If import tkinter is displayed, the installation is successful.
hisisoc@ubuntu62:~$ python3.7.5 Python 3.7.5 (default, Mar 3 2020, 13:58:02) [GCC 7.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter >>>