4

I updated my python distribution yesterday to EPD 7.3-2 (64-bit). I am working on a mac with snow leopard. Now the plot device of matplotlib is broken in at least two ways:

  1. the "save" button doesn't work and makes the terminal or ipython crash and
  2. the only way to see the figure is to have it in front of you, there is no python figure icon in the dock.

I did my homework and these same problems were reported here and here.

I tried to follow the instructions to fix this given in here, but this is the error that I get:

$python install_pythonw.py `which python`/../..
/Library/Frameworks/EPD64.framework/Versions/Current/.Python does not exist; exiting.

Indeed, I looked at the given folder and I could not find a .Python file. I added a comment at the answer to this problem but so far no one has replied to it :( :( Any idea of how to fix this? thanks!

Community
  • 1
  • 1
Laura
  • 1,822
  • 3
  • 15
  • 23
  • Try changing the backend of matplotlib. One way to do this is to modify the `backend` setting in the configuration file. See http://matplotlib.org/users/customizing.html#customizing-matplotlib for more information. – Warren Weckesser Dec 07 '12 at 15:59
  • I am sorry Warren but I don't understand: I should change the backend to what exactly? the page you referred to does not seem to have anything specific about this :( – Laura Dec 07 '12 at 20:14
  • I think the default is 'MacOSX'. You could try 'WXAgg' or 'TkAgg'. – Warren Weckesser Dec 07 '12 at 20:31
  • Also, instead of using the save button you can use the `savefig` command. – tiago Dec 07 '12 at 21:23
  • Thank you Tiago, I know about that option, but that is pretty cumbersome for me. In addition, even using the savefig command, ipylab or the terminal crashes after doing 4 or 5 consecutive plots. – Laura Dec 10 '12 at 05:37
  • 1
    By the way, complex procedure that invoked `install_pythonw.py` is most likely not the solution to your problem, and it was a very old fix for much older versions of python! – tiago Dec 10 '12 at 07:59
  • Maybe also try to update matplotlib to the newest version after you re-installed Enthought. I am using Enthought for years and maybe had this problem once or twice. Unfortunately I have no experience with 7.3-2 on Snow Leopard, but I can tell you that it (the 64-bit version) works fine here on my MBP Retina with Mountain Lion. I am using the pyqt version installed via homebrew. – K.-Michael Aye Jan 08 '13 at 03:24

1 Answers1

2

I have seen this problem a few times, and it seems to be a problem in some backends. Also, it doesn't seem normal that your session crashes after 4 or 5 plots. In particular, the MacOSX backend seems buggy.

As you installed the EPD, I think it's less likely that your installation is broken. The solution seems to be using a different backend. You can try with ipython --pylab a few backends, try their features and see if the save button works. You can try the following:

ipython --pylab=wx
ipython --pylab=tk
ipython --pylab=osx

The last one is the option that you're probably using right now, so perhaps not the best. If you just call ipython --pylab, it will use the default backend from your ~/.matplotlib/matplotlibrc file. Once you find a working backend you can change the default by editing that file. Look for a line like this:

backend      :  MacOSX

(your version may have a different backend.) Just change that setting to WXAgg, TkAgg, or Qt4Agg. With the --pylab option the names are slightly different, they don't have the Agg part. My favourite backend for OSX is the Qt4Agg backend, but I don't think it ships with EPD and the save button also doesn't work! But either WXAgg or TkAgg should work fine.

Other ways of changing the backend in a script are:

import matplotlib
matplotlib.use('WXAgg')

or

matplotlib.rcParams['backend'] = 'WXAgg' 
Community
  • 1
  • 1
tiago
  • 22,602
  • 12
  • 72
  • 88
  • Hi Tiago, thanks for your answer. I tried doing what you suggested and it didn't work :( As I mentioned in my original post, there are 2 problems (at least). And even if I get to save the figure with pylab.savefig(), I still cannot solve the second point, and that is that the only way to see the plots is to minimize everything else and have the figure right in the front of the screen :( :( At this point I even tried to revert to my old version, but doing the enthought uninstall (remove-EDP) command just removes some of the stuff, but I still don't get it to work as before. – Laura Dec 13 '12 at 06:33
  • @Laura, sounds like your install is broken. You can just delete the directory where you installed EPD to. – tiago Dec 13 '12 at 06:37
  • Hi Tiago, thanks, I will try to uninstall EPD completely and install it again. – Laura Dec 17 '12 at 18:41