0

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 https://github.com/polyanskiy/refractiveindex.info-scripts

  • 1
  • 1
    Welcome to Ask Ubuntu! Could you please edit question to add a few details for clarification? What's the program? How did you install the Python interpreter in question and the mathplotlib module? Thanks. – David Foerster May 17 '18 at 13:42
  • i have tried it by the command "sudo apt-get install python3-matplotlib". then when i have tried to run the program there is another problem saying Traceback (most recent call last): File "example.py", line 6, in <module> import matplotlib.pyplot as plt ImportError: No module named matplotlib.pyplot wht is the problem and how to install the matplotlib properly? – Atrayee Hazra May 17 '18 at 13:44
  • @AtrayeeHazra It depends on how you installed Python. Tell us how you installed Python and what the output of which python or which python3 is. – Steve May 17 '18 at 13:49
  • 1
    »python 2.7.12« is not using 'python3-matplotlib', but python-matplotlib. Please install python-matplotlib too. – Knud Larsen May 17 '18 at 14:02
3

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

| improve this answer | |
1

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
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.