Roman
Roman

Reputation: 131228

How to get matplotlib working under IPython?

When I type

import matplotlib.pyplot as plt

in my IPython notebook I get

ImportError: No module named matplotlib.pyplot

Shouldn't be this module installed by default? Do I need to extra install it. If it is the case, how can I do it. I use virtual environment on Linux to install stuff (including IPython).

Upvotes: 1

Views: 7482

Answers (3)

Sarvesh Jayaraman
Sarvesh Jayaraman

Reputation: 53

In case you are trying on Python 3, you can install it using:

python3-matplotlib

Hope it helps!

Upvotes: 1

ijmarshall
ijmarshall

Reputation: 3487

Matplotlib is not installed by default, there are instructions on the IPython install page to install on linux:

Optionally install additional tools for scientific computing: On Ubuntu or other Debian-based distributions, type at the shell:

sudo apt-get install python-matplotlib python-scipy python-pandas python-sympy python-nose

On Fedora 18 and newer related distributions, use:

sudo yum install python-matplotlib scipy python-pandas sympy
python-nose

Though if you are using a python virtualenv, you should be able to use pip install matplotlib when you are in the virual environment.

Upvotes: 3

Dr. Jan-Philip Gehrcke
Dr. Jan-Philip Gehrcke

Reputation: 35796

In my Python setup (2.7.3, Linux), I installed matplotlib as well as IPython via pip. matplotlib is available from the normal Python interpreter as well as from IPython (as expected). The order of installation does not matter.

And no, IPython should not have matplotlib installed by default, this does not make sense.

Upvotes: 2

Related Questions