2012-10-28 39 views
1

我的MacPorts通过对山狮安装Python 2.7版和1.1.1 matplotlib,当我运行以下命令:在最后一行我得到下面的错误信息Matplotlib和GTKAgg和OS X

import matplotlib 
    matplotlib.use('GTKAgg') 
    import matplotlib.pyplot as plt 

。在互联网上环顾四周后,我所看到的唯一“解决方案”就是使用'Agg'作为后端而不是'GTKAgg',但是当我这样做时它会运行(并且终止没有任何错误),但没有任何绘制。上面的行在我的Windows XP上正常工作。任何人有任何建议?

错误消息:

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

+0

“但没有任何情节” - 你正在使用'plt.show()'? –

+0

你尝试过'MacOSX'或'CocoaAgg'后端吗? – unutbu

+0

是的,我正在使用plt.show()。我刚刚尝试过MacOSX和CocoaAgg后端。在后者上,我得到了剧情窗口,但随后反复得到以下内容:**错误消息:** AttributeError:'FigureCanvasMac'对象没有任何属性'restore_region' –

回答

0

你需要select python27为主要和默认的Python。

-1

感谢您的帮助,但这个问题的所有的你已经用自己通过MacPorts的更新安装最新版本(S)解决/升级。我不确定是因为Matplotlib还是Python的更新,或者两者兼而有之,但现在我所有的东西都运行正常。