ImportError: No module named matplotlib.pyplot in Python

Dung Do Tien Dec 06 2021 74

Hello Guys, I'm just studying Python one month before and I practiced with matplotlib with basic simple like this

import matplotlib.pyplot as pylot

lst_radius = [1.0, 1.2, 1.4, 1.6, 1.8, 2.0]
pointer = [1.9434, 4.8773, 8.2545, 9.9882, 11.9822, 54.0993 ]

pylot.plot(lst_radius, pointer)
pylot.show()

But when running this code I got an exception ImportError: No module named matplotlib.pyplot.

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

I'm using Python 3.8.2 and running on window 10.

Do you have any suggestions for me?

Thank you so much.

Have 3 answer(s) found.
  • L

    Le Ba Tuan Anh Dec 06 2021

    You can run the command below to install matplotlib package in Python 3:

     python3 -m pip install matplotlib --user

    And it's worked for me!

  • A

    Armin Habibi Dec 06 2021

    You need to install matplotlib, by using the command below:

    Python2:

    sudo apt-get install python-matplotlib

    Python3:

    sudo apt-get install python3-matplotlib

    It really works for me.

  • M

    Mahtab Dec 06 2021

    You are using Python 3, you can use pip3 to install matplotlib package:

    sudo pip3 install matplotlib 

    Or

    sudo apt-get install python3-matplotlib
    
Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close