close

[Solved] ImportError: No module named matplotlib.pyplot

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to import matplotlib.pyplot but I am facing following error ImportError: No module named matplotlib.pyplot in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ImportError: No module named matplotlib.pyplot Error Occurs ?

I am trying to import matplotlib.pyplot but I am facing following error.

Traceback (most recent call last):
File "./my_plot_drawing.py", line 3, in <module>
  import matplotlib.pyplot as plt
ImportError: No module named matplotlib.pyplot

How To Solve ImportError: No module named matplotlib.pyplot Error ?

  1. How To Solve ImportError: No module named matplotlib.pyplot Error ?

    To Solve ImportError: No module named matplotlib.pyplot Error Here all you need to do is just install matplotlib. Just use this pip command to install matplotlib: pip install matplotlib Now, Your error must be solved. And you can import matplotlib.pyplot and use in your code. Second Solution is If You are using python 2.x and you are using linux then use this command: sudo apt-get install python-matplotlib And If You are using Anaconda3 then just run this command: conda install -c conda-forge matplotlib.

  2. ImportError: No module named matplotlib.pyplot

    To Solve ImportError: No module named matplotlib.pyplot Error Here all you need to do is just install matplotlib. Just use this pip command to install matplotlib: pip install matplotlib Now, Your error must be solved. And you can import matplotlib.pyplot and use in your code. Second Solution is If You are using python 2.x and you are using linux then use this command: sudo apt-get install python-matplotlib And If You are using Anaconda3 then just run this command: conda install -c conda-forge matplotlib.

Solution 1: Install matplotlib

Here all you need to do is just install matplotlib. Just use this pip command to install matplotlib.

pip install matplotlib

Now, Your error must be solved. And you can import matplotlib.pyplot and use in your code.

Solution 2: For python 2.x

If You are using python 2.x and you are using linux then use this command.

sudo apt-get install python-matplotlib

Solution 3: For Python 3.x

If You are using python 3.x and you are using linux then use this command.

sudo apt-get install python3-matplotlib

Solution 4: using Anaconda3

If You are using Anaconda3 then just run this command.

conda install -c conda-forge matplotlib

Solution 5: Use this command.

I just use this command.

python3 -m pip install matplotlib

Then I just import

import matplotlib.pyplot as plt

And My error was solved.

Solution 6: reinstall matplotlib

First of all uinstall matplotlib

pip uninstall matplotlib

Then Install matplotlib with desire python version for example python3

python3 -m pip install matplotlib

For python2

python2 -m pip install matplotlib

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment