我的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
「但沒有任何情節」 - 你正在使用'plt.show()'? –
你嘗試過'MacOSX'或'CocoaAgg'後端嗎? – unutbu
是的,我正在使用plt.show()。我剛剛嘗試過MacOSX和CocoaAgg後端。在後者上,我得到了劇情窗口,但隨後反覆得到以下內容:**錯誤消息:** AttributeError:'FigureCanvasMac'對象沒有任何屬性'restore_region' –