In this Python tutorial, we will discuss the attribute error “matplotlib is currently using agg a non-gui backend”. Here we’ll cover the reason and solution related to this error using matplotlib. And we’ll also cover the following topics:
- Error : matplotlib is currently using agg a non-gui backend
- Solution : matplotlib is currently using agg a non-gui backend
Error: matplotlib is currently using agg a non-gui backend
When we get the Warning: Matplotlib is currently using agg a non-gui backend we can’t see the figures or we can say that visualization of plots is not possible.
Basically, this error means that we have to install the GUI backend.
GUI stands for the graphical user interface. It is a user interface through which we can interact with devices and visualize the plots also. In Python, we have multiple ways of developing GUI, but the most commonly used method is Tkinter.
A Non-GUI user interface is a machine that allows the user to interact with the machine without any graphics only with the text.
Also, check: module ‘matplotlib’ has no attribute ‘plot’
Solution: matplotlib is currently using agg a non-gui backend
Solution #1
In matplotlib, to solve this error, install the GUI-backend tk i.e. Tkinter.
Linux
- Use the below mention command to install GUI backend.
Syntax:
sudo apt-get install python3-tk
Jupyter Notebook
- Use the bellow mention command to install GUI backend in Jupter Notebook.
Syntax:
pip install tk
- After installation of Tkinter in jupyter notebook, import the tkinter library.
Syntax:
from tkinter import *
Anaconda Distribution
If you have Anaconda Prompt in your system, you can easily install Tkinter, from here using the below-mentioned commands. If you are not sure about whether you have it or not, you can easily see it in your machine Windows Start Menu.
- Use the bellow mention command to install GUI backed in Anaconda.
Syntax:
conda install tk
- After installation of Tkinter in anaconda, import the tkinter library.
Syntax:
import tkinter
Solution#2
Install any of the GUI backends to solve this error using matplotlib python. So here we will install the PyQt5 GUI toolkit. It’s a Python interface to Qt, a robust and widely used cross-platform GUI framework. PyQt5 is a programming language that combines Python and the Qt library.
Jupyter Notebook
- To install PyQt5 in Jupyter Notebook, use the below command:
Syntax:
pip install pyqt5
Linux
- To install PyQt5 in Ubuntu Linux or Debian Linux, use the below command:
Syntax:
sudo apt-get install python3-pyqt5
CentOS 7
- To install PyQt5 in CentOs 7, use the below command:
Syntax:
yum install qt5-qtbase-devel
Redhat based System
- To install PyQt5 in an RPM-based system i.e readhat based use the below command:
Syntax:
yum install PyQt5
Anaconda Distribution
If you have Anaconda Prompt in your system, you can easily install PyQt5, from here using the below-mentioned commands.
Use the below mention command to install GUI backed in Anaconda.
Syntax:
conda install pyqt
You may also like to read the following Matplotlib tutorials.
- Matplotlib Pie Chart Tutorial
- Matplotlib scatter plot color
- Matplotlib Plot NumPy Array
- Matplotlib update plot in loop
- Matplotlib unknown projection ‘3d’
- Matplotlib 1.3.1 requires nose which is not installed
In this Python tutorial, we have discussed “ “matplotlib is currently using agg a non-gui backend” ” and we have also covered the reason and solution related to it. These are the following topics that we have discussed in this tutorial.
- Error: matplotlib is currently using agg a non-gui backend
- Solution : matplotlib is currently using agg a non-gui backend
I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.