close

[Solved] ModuleNotFoundError: No module named ‘matplotlib’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ModuleNotFoundError: No module named ‘matplotlib’ 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 ModuleNotFoundError: No module named ‘matplotlib’ Error Occurs?

Today I get the following error ModuleNotFoundError: No module named ‘matplotlib’ in python.

How To Solve ModuleNotFoundError: No module named ‘matplotlib’ Error ?

  1. How To Solve ModuleNotFoundError: No module named 'matplotlib' Error ?

    To Solve ModuleNotFoundError: No module named 'matplotlib' Error Is the standard mac python and since it doesn't have matplotlib you should always start your script with the one installed with ports.

  2. ModuleNotFoundError: No module named 'matplotlib'

    To Solve ModuleNotFoundError: No module named 'matplotlib' Error Is the standard mac python and since it doesn't have matplotlib you should always start your script with the one installed with ports.

Solution 1

You have two pythons installed on your machine, one is the standard python that comes with Mac OSX and the second is the one you installed with ports (this is the one that has matplotlib installed in its library, the one that comes with macosx does not).

/usr/bin/python

Is the standard mac python and since it doesn’t have matplotlib you should always start your script with the one installed with ports.

If python your_script.py works then change the #! to:

#!/usr/bin/env python

Or put the full path to the python interpreter that has the matplotlib installed in its library.

Solution 2

If you are using Python 2, just run

sudo apt-get install python-matplotlib

The best way to get matplotlib is :

pip install matplotlib

cause the previous way may give you a old version of matplotlib

Summery

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? Thank You.

Also, Read