Matplotlib and GTKAgg and OS X
I installed python 2.7 and matplotlib 1.1.1 on Mountain Lion via Macports and when I run the following:
   import matplotlib
   matplotlib.use('GTKAgg') 
   import matplotlib.pyplot as plt
on the last line I get the error messages below. After looking around on the internet the only "solution" I've seen is to use 'Agg' as the backend instead of 'GTKAgg', but when I do this it runs (and terminates without any errors) but nothing plots. The lines above work fine on my Windows XP. Anyone have any suggestions?
Error message:
 line 2, in import matplotlib.pyplot as plt  
 File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pyplot.py", line 95, in new_figure_manager, draw_if_interactive, _show = pylab_setup()  
 File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/init.py", line 25, in pylab_setup globals(),locals(),[backend_name])  
 File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,  
 File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 52, in cursors.MOVE : gdk.Cursor(gdk.FLEUR), RuntimeError: could not create GdkCursor object  
你需要select python27作为你的主要和默认的Python。 
Thanks all of you for your help but the matter has resolved itself with a more recent version(s) installed via a Macports update/upgrade. I'm not sure whether it was because of an update on Matplotlib, or Python, or both, but all my stuff runs OK now.
链接地址: http://www.djcxy.com/p/54728.html