1
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import style
style.use('ggplot')

gives me an error message:

Traceback (most recent call last): File "", line 2, in ImportError: No module named 'matplotlib'

So I go to cmd and typed pip install matplotlib but I get 'Requirement already satisfied'.

I am not really sure what to do....

8
  • what version of python are you using to run your code? I men how are you running your code. Commented May 27, 2017 at 2:38
  • Just checking, are you sure you installed it for the correct version of Python? Commented May 27, 2017 at 2:39
  • 2
    quite simply you are mixing wrong python versions or wrong virtualenvs Commented May 27, 2017 at 2:40
  • Hi, I am using Pycharm and I believe the version is 3.5 Commented May 27, 2017 at 2:41
  • so if I were to remove old versions then it should work? Commented May 27, 2017 at 2:42

2 Answers 2

3

Based on the information you have provided. Go to PyCharm Preferences. Then go to Project:your-project-name, inside this to Project Interpreter. enter image description here

and make sure this interpreter has installed matplotlib. Othersiwe, click on the + sign and add the library you need.enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Nice nice nice, just good, that's an example of a perfect answer ;)
Sorry and thank you. I solved the problem. I was doing 'pip install matplotlib' in a different directory. For some reason, I had two different directories 'Scripts', one of which contains pip and the other doesnt.
@JunJang, it's okay. Just consider this solution as an alternative. You probably are using virtual environments (not sure).
1

If you want to install a package in pycharm, follow the instructions here:

https://www.jetbrains.com/help/pycharm/2017.1/installing-uninstalling-and-upgrading-packages.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.