In this Python tutorial, we will discuss the error “module ‘matplotlib‘ has no attribute ‘artist’“. Here we’ll cover the reason related to this error using matplotlib. And we’ll also cover the following topics:
- module matplotlib not installed
- issue in matplotlib module
- envirionment issue
AttributeError: module ‘matplotlib’ has no attribute ‘artist’
Error#1: module ‘matplotlib’ not installed
Here we are going to discuss the error Attribute Error: module ‘matplotlib’ has no attribute ‘artist’ in python. Basically, this error statement comes when we import the pandas library.
Reason: This first reason is that maybe matplotlib is not installed in your system.
Now let’s see the solution for this:
Jupyter Notebook:
- Install matplotlib using pip command.
Syntax:
pip install matplotlib
- To check, whether it is installed or not check its version.
Syntax:
import matplotlib
print(matplotlib.__version__)
Anaconda Distribution:
If you have Anaconda Prompt in your system, you can easily install matplotlib, 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.
- Install matplotlib using conda command:
Syntax:
conda install matplotlib
- To check whether matplotlib installed or not, check it’s version:
Syntax:
import matplotlib
print(matplotlib.__version__)
For details on the installation of matplotlib, check: How to install matplotlib python
Error#2: Issue in matplotlib module
Here we are going to discuss the error Attribute Error: module ‘ matplotlib has no attribute ‘artist’ in python.
Reason: module ‘matplotlib’ is not properly installed.
If you are sure, the matplotlib module is already installed in your system but still, you are facing the above-mentioned attribute error. The reason must be, it is not properly installed.
Let’s discuss the solution:
Jupyter Notebook:
- Unintsall the already installed version.
Syntax:
pip uninstall matplotlib
- Reinstall the matplotlib module:
Syntax:
pip install matplotlib
Anaconda Distribution:
If you have an anaconda prompt, use the below commands:
- Unintsall the already installed version.
Syntax:
conda uninstall matplotlib
- Reinstall the matplotlib module:
Syntax:
conda install matplotlib
Also, check: modulenotfounderror: no module named ‘matplotlib’
Error#3: environemt issue
If you follow the above mention error reason and solution, and still you have the error. Then may the there is an issue with the environment.
Let’s see the solution for this:
Jupyter Notebook:
In the Juypter notebook, to solve this error we have to restart the kernel.
To restart the kernel follow the following steps:
- Open the jupyter notebook.
- Click on Kernel on top of jupyter menu.
- Then click on Restart .
This will reset your notebook and also remove the defined variables and methods.
Anaconda Distribution:
In an anaconda, we can activate and deactivate the environment. So to activate the environment follow the below code:
conda activate <envirinemnt name>
And if you don’t know the environment use this command:
conda env list
In this Python tutorial, we have discussed “module ‘matplotlib’ has no attribute ‘artist’” and we have also covered the reason and solution related to it. These are the following topics that we have discussed in this tutorial.
- module matplotlib not installed
- issue in matplotlib module
- envirionment issue
You may also like to read the following Matplotlib tutorial.
- Matplotlib plot a line (Detailed Guide)
- Matplotlib fill_between – Complete Guide
- Matplotlib tight_layout – Helpful tutorial
- Matplotlib unknown projection ‘3d’
- Matplotlib is currently using agg a non-gui backend
- Matplotlib 1.3.1 requires nose which is not installed
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.