No plot window shows up with matplotlib.pyplot run with Enthought Canopy python editor on Mac OS X 10.8.5 (Mountain Lion)

user3196617 picture user3196617 · Jan 15, 2014 · Viewed 8.9k times · Source

I've installed Enthought Canopy 64-bit onto my Mac OS X v10.8.5 (Mountain Lion), and within the Canopy command-line I can enter import matplotlib and matplotlib.pyplot.plot([1,2,3,4]) and a plot window opens up just fine.

But when I run the exact same two lines in the Canopy editor window I get nothing, no plot window, no error.

Notes: When I run matplotlib.get_backend() I get an output of Qt4Agg, which is the same no matter if I run it in the command line or in the editor window.

ANOTHER NOTE: for some mysterious reason, when I click Canopy → Preferences I see that "Canopy is NOT your default Python environment", which is weird, because I when I run import sys then sys.prefix I get /Users/damon/Library/Enthought/Canopy_64bit/User, which is supposed to guarantee that Canopy IS my default Python environment.

How can I fix this?

Answer

Jonathan March picture Jonathan March · Jan 15, 2014
  1. Part of the magic of IPython is that when you plot in IPython's pylab mode, you don't need to explicitly invoke pyplot.show(). From your script, you do need to.

    https://support.enthought.com/entries/25750190-Modules-are-already-available-in-the-pylab-python-prompt-but-not-in-a-script (bottom of article)

  2. Within Canopy itself, Canopy User Python is indeed always your Python environment. This preference option is for what happens in Terminal (as it explains in smaller letters just above the button).