I'm trying to run a simple code in Pycharm Community Edition 4.5.3 to display a graph with some points using matplotlib

import matplotlib.pyplot as plt

[5,7,10,13,8,14,7,11,5,13,9,4,6,12,14,8,10,6,13,8], 'ro')

plt.axis([0, 15, 0, 15])

Although matplotlib is installed properly Pycharm is not recognizing it. I'm getting this error message on running the above code in Pycharm

ImportError: No module named 'matplotlib'

  • How have you installed matplotlib? – A.B. Aug 27 '15 at 17:39

it seems like you have installed python more than one and matplotlib library installed with python that currently not used by Pycharm by default. so in your python script add #!/usr/bin/env python or full path of python interpreter that has matplotlib.

if you are using python installed by system by default then use python-matplotlib if you install python3-matplotlib then it will create problem or vise versa . in this situation you have to mention full path of python interpreter that you want to use .

i just installed only python-matplotlib using

sudo apt-get install python-matplotlib

and able to run code using

python test.py
| improve this answer | |

Install the package python-matplotlib

sudo apt-get install python-matplotlib

or for Python3

sudo apt-get install python3-matplotlib
| improve this answer | |

I think your problem like mine. I tested import matplotlib in python shell, it is OK. But shows error in Pycharm. This is because Pycharm don't know the path of site-packages.

  1. You should add path of site-packages (for me C:\Program Files\Python 3.5\lib\site-packages) to PATH or
  2. In your code add these

    import sys    
    sys.path.append(r"C:\Program Files\Python 3.5\lib\site-packages")
    import matplotlib.pyplot as plt

I think it will help you :)

| 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.