I have been through the process of installing matplotlib on my Ubuntu 12.04 computer. However, when I try to run a test program, I get the following error:
Traceback (most recent call last):
File "../py33/test.py", line 2, in <module>
import matplotlib.pyplot as plt
ImportError: No module named 'matplotlib'
I am trying a sample program from matplotlib's website (basic_example). I just don't understand why it says there is not module matplotlib, even though I have definitely installed it (using sudo apt-get install python-matplotlib
, and have done sudo apt-get build-dep python-matplotlib;
I also tried pip install matplotlib
, as I was told to do that, after installing Python itself, if I wanted to install other binaries).
Best Answer
I believe you are using
python3
. So in order to run your script you need either to use python2.x or to make sure you havematplotlib v1.2
or higher. This is becausematplotlib
does not support python3 before v1.2.I am using
matplotlib v1.1
withpython2.7
and I have no problem. I tried to do a simpleimport matplotlib
withpython3
and it gives the same error as you.