I am the rawest of raw newbies. I have just installed IPython on a Mac (MacOS 10.7.5) following the instructions for anaconda on http://ipython.org/install.html, with no obvious errors. I now want to work my way through the example notebooks. In notebook "Part 1 - Running Code", everything works as it should until I get to
%matplotlib inline
Then I get the error message
ERROR: Line magic function %matplotlib
not found.
Everything after that works, except that plots, instead of appearing inline, pop up in a new window.
Try:
import IPython
print(IPython.sys_info())
Does it report that you are on 'ipython_version'
1.0+?
You might be picking up an older version of IPython that do not have the %matplotlib
magic.
If you have Anaconda, just do conda update ipython
from the command line. No need for removal, easy_install and all the rest.
if you run the notebook through shell, try the command
ipython notebook --pylab=inline
I had this problem on Windows, but I believe it will work the same way:
- Get rid of the old IPython. The command is
conda remove ipython
.
- Get
easy_install
if you don't have it. Follow the instructions to install easy_install
for your system.
- Use
easy_install
to reinstall the newest IPython. The command is easy_install ipython[all]
, just like it shows on the site.
With Conda's default IPython gone, it should indicate it's loading IPython 1.0.0. You can make sure by running either IPython or the IPython Notebook and running the command %lsmagic
. If matplotlib
is in the list, you've got it.
If you run the notebook through shell, try the command
ipython notebook --pylab=inline
It works for me.
Make sure, you use the right installation of ipython
In my case, I have system-wide Python installation for application development and beside that, also anaconda for data analysis (to be used with ipython
notebooks).
When starting ipython
notebook, I shall set PATH
properly to use anaconda version of ipython
.
Forgetting to set PATH
, I use system-wide installed ipython
which does not serve running notebooks well resulting in the complain about %matplotlib inline
as noted in OP.
When I set PATH
properly and used anaconda version of python and ipython
, all goes well.
instead of the inline command, I simply put this after the plot
matplotlib.pyplot.show()