Question

I'm new to python and Ipython. I'm following the data analysis with pandas on youtube. the link

I installed Anaconda and then started to use Ipython on Windows 8.1

For several commands, it seems OK

In [2]: print 5
5

But when I tried to followe the tutorial online it seems that my Ipyhon has got some problems,

In [3]: %pylib inline
ERROR: Line magic function `%pylib` not found.

Also, I just copies the code from the tutorials, just very simple codes like this

In [4]:plot(arange(10))
NameError                                 Traceback (most recent call last)
<ipython-input-6-353c92d67d6b> in <module>()
----> 1 plot(arange(10))

NameError: name 'plot' is not defined

After "imported matplotlib", it still didn't work.

Also, the code a = arange(10) didn't work. I have to use it like this:

import numpy as np
a = np.arange(10)

But the tutor in this video didn't use it like this.

I think it should be associated with the configuration with anaconda or Ipython?

But I'm not sure about this and I don't know how to figure it out. I'm using the latest version of anaconda on windows 64bit.

Any suggestions? Thanks!

Était-ce utile?

La solution

  • use %pylab inline or %pylab to enable pylab mode. This will alter the event loop either to show plots inline (notebook) or to display them in different window without interfering the code execution (CLI).
    • Executing %pylab will set ipython to handle matplotlib nicely, and will also commit from pylab import * that will put numpy and matplotlib commands inside your default namespace.
    • equivalent way to that, when you invoke IPython, use `ipython --pylab [notebook|qtconsole|etc..]. In windows, you can either do that from console or alter a shortcut to add command line arguments.
    • You can change IPython system wide configuration to load pylab, see http://ipython.org/ipython-doc/stable/config/overview.html#flags

See this answer for more information: https://stackoverflow.com/a/21457629/3245308

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top