How do I properly install matplotlib?

I installed matplot.lib by using the command sudo apt-get install python3-matplotlib.

While running a program written in python it is showing

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

What is the problem and how do I install matplotlib properly?

I am trying to run a program that calculates refractive index and the link is

7

2 Answers

apt-get install python3-matplotlib ...... it is python 2.7.12 : import matplotlib.pyplot as plt

python 2.7.12 is not using 'python3-matplotlib', but python-matplotlib.

Please install python-matplotlib too

Try installing matplotlib using pip

pip3 install matplotlib

And if pip3 is not installed on your system try installing pip using following command

sudo apt-get install -y python3-pip

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like