2015-10-25 85 views
5

我在Python和Linux的真正新的,我需要幫助可見,我試圖用matplotlib用於顯示以下列方式情節簡單:圖是沒有使用matplotlib plt.show()

from matplotlib import pyplot as plt 

plt.plot([5,6,7,8], [7,3,8,3]) 
plt.show() 

但是,當我運行python3 test.py,我得到下面的輸出:

/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_gtk3agg.py:18: UserWarning: The Gtk3Agg backend is known to not work on Python 3.x with pycairo. Try installing cairocffi. 
    "The Gtk3Agg backend is known to not work on Python 3.x with pycairo. " 
Traceback (most recent call last): 
    File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_gtk3agg.py", line 69, in on_draw_event 
    buf, cairo.FORMAT_ARGB32, width, height) 
NotImplementedError: Surface.create_for_data: Not Implemented yet. 
Traceback (most recent call last): 
    File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_gtk3agg.py", line 69, in on_draw_event 
    buf, cairo.FORMAT_ARGB32, width, height) 
NotImplementedError: Surface.create_for_data: Not Implemented yet. 
/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_gtk3.py:215: Warning: Source ID 7 was not found when attempting to remove it 
    GLib.source_remove(self._idle_event_id) 

和一個空的花紋無白色帆布:

enter image description here

有什麼不對?我該如何解決它?

+0

一定是有問題與Linux上的圖形模塊。可能需要重新安裝。 –

回答

15

正如你可以看到:

"The Gtk3Agg backend is known to not work on Python 3.x with pycairo." 

這樣一來,建議介紹的是:

Try installing cairocffi. 

installation guidecairocffi是相當直接的。如果依賴滿足它很簡單,只要:

pip install cairocffi 

1)Python 3.x的依賴應該邏輯是:

sudo apt-get install python3-dev 
sudo apt-get install libffi-dev 
+1

這個作品! ubuntu 14.04與Python 3.4(64位) –

相關問題