Search code examples
python-2.7numpyenthoughtcanopy

Why can't I use NumPy functions in Canopy's IPython?


I am struggling to use basic NumPy functions in my Python programme on Enthought's IPython, such as 'pi' and 'logspace'

It also says that the term 'plot' is undefined - has it changed?

Thanks so much


Solution

  • Had you imported numpy and matplotlib? If I had to guess, you used to start ipython with the --pylab flag. That flag is the destroyer of minds and hearts, and was recently deprecated.

    A more merciful approach would be explicit imports that maintain namespaces, i.e.,

    import numpy as np
    import matplotlib.pyplot as plt
    %matplotlib inline
    

    However, if you want the mayhem to continue, you can execute from pylab import * at the top of your notebook.