2015-10-25 14 views
5

Sono veramente nuovo in Python e Linux e ho bisogno di aiuto, ho cercato di usare matplotlib per mostrare una trama semplice nel seguente modo:Parcelle non sono visibili utilizzando matplotlib plt.show()

from matplotlib import pyplot as plt 

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

ma, quando corro python3 test.py, ottengo il seguente output:

/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) 

e una figura vuota senza tela bianchi:

enter image description here

Cosa c'è che non va? Come posso ripararlo?

+0

deve essere un problema con i moduli grafici su Linux. Potrebbe essere necessario reinstallarlo. –

risposta

15

Come si può vedere:

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

E così il suggerimento presentato è:

Try installing cairocffi. 

Il installation guide per cairocffi è abbastanza straight-forward. Se le dipendenze sono soddisfatti è semplice come:

pip install cairocffi 

1) le dipendenze per Python 3.xdovrebbe logicamente:

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

Funziona !!! ubuntu 14.04 con python 3.4 (64bit) –

Problemi correlati