5

I'm really new in Python and Linux and I need help, I tried to use matplotlib for showing a simple plot in the following way:

from matplotlib import pyplot as plt

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

But, when I run python3 test.py, I get the following 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)

and an empty figure without white canvas:

enter image description here

What is wrong? How can I fix it?

1
  • Must be a problem with the graphics modules on Linux. May need to be reinstalled. Commented Oct 25, 2015 at 13:14

1 Answer 1

15

As you can see:

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

And so the suggestion presented is:

Try installing cairocffi.

The installation guide for cairocffi is pretty straight-forward. If the dependencies1 are met it is as simple as:

pip install cairocffi

1) The dependencies for Python 3.x should logically be:

sudo apt-get install python3-dev
sudo apt-get install libffi-dev
Sign up to request clarification or add additional context in comments.

1 Comment

Shouldn't it be pip3 install cairocffi?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.