3

Um... I wanted to import matplotlib in Python IDLE, but it said

>>> import matplotlib
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import matplotlib
ModuleNotFoundError: No module named 'matplotlib'

I've already tried pip thing and the conda thing in terminal. It said

# All requested packages already installed.
# packages in environment at /Users/Dan/anaconda:

Then! what's the problem here?

4
  • The"pip thing, conda thing"....how have you tried it? Commented Apr 2, 2017 at 15:33
  • Are you sure you installed matplotlib for the correct Python version? Commented Apr 2, 2017 at 15:33
  • And are you importing it from within the conda? Commented Apr 2, 2017 at 15:37
  • I put 'pip install matplotlib, conda install matplotlib' in terminal, but both of them didn't work. I installed anaconda for python 3.x. Commented Apr 2, 2017 at 17:02

2 Answers 2

5

You may have installed Matplotlib to Python 2.7 and not Python 3.6. To install it to Python3 you need to use pip3:

pip3 install matplotlib

Then open python3.6 from your terminal (not idle) and try importing matplotlib from there. This way you can use any text editor you wish, and run your code from the terminal.

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

16 Comments

I already tried the first one, and I just tried the second one, but it didn't work. Same problem occured. I'm using Python 3.6, and I installed anaconda yesterday. The command that I used is terminal in mac.
As a test: open ipython from your terminal and try importing matplotlib from there
how can I open i python from terminal?
type 'ipython' into the terminal
'import matplotlib' does work, but 'import matplotplib.pyplot as plt' doesn't.
|
5

I had the same issue using the same command in IDLE. I just figured it out. go to your terminal and enter:

pip3.6 install matplotlib

I was using pip3 instead of pip3.6

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.