New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gtk3Agg backend (Ubuntu 14.04) #2976
Comments
@farzia Can you take a look at this? |
This might be a somewhat related issue: https://bugzilla.redhat.com/show_bug.cgi?id=1049624 I tried out a few different backends, but that just produced similar errors. |
The redhat issue is an issue with setting the default backend to one that is not installed (which looking at how we do thin is I can not reproduce this with 1.3.1, but on 13.10 |
I think this is a know issue the release version of pycairo does not implement this function. AFAIK this is one of the reasons that the master branch now supports cairocffi as an alternative to pycairo. I think that @mdboom might know more. |
@jenshnielsen is right. To use the GTK3 backend with Python 3 you have to use cairocffi instead of pycairo. Luckily it's easy to install through pip:
|
@timovwb Thanks for the answer. I had to use:
But the example still doesn't work:
|
Are you using the master branch? As I wrote above only the master branch has support for cairocffi at the moment. It does not work in 1.3.1 or lower nor in the 1.3.x branch. |
Ok, now I understand. I am using:
Going to try to add this repository: https://launchpad.net/~takluyver/+archive/matplotlib-daily |
That looks like an outdated PPA, latest version there is 1.3.0. It's possible to install matplotlib git master through pip, maybe someone else can help you with the correct command. |
It's not really 1.3.0, I just haven't bumped the version number in a while. However, it's not building at present because of #2916 |
This is a known issue on all released versions of matplotlib, and is explicit in the error message:
matplotlib master has a fix to make this compatible with cairocffi, but with pycairo it still doesn't work (and may never, as pycairo appears to be abandoned). See #1227. Closing as already fixed. |
So I guys I managed to get the plots working in Python 3.x by using:
but is there a better way of doing this without importing the entire namespace? |
Which version of Matplotlib is this. All recent versions (al least 1.4.x) should support cairocffi out of the box without the need to do any special imports. |
|
Can you explain in some more detail what you are trying to do and any error messages you get? As stated above plotting using the GTK3Agg backend should work without any need for work arounds |
Downloaded matplotlib and numpy via pip. Launched the script and triggered "Not Implemented backend" error, and also the warning message "Gt3Agg is known to not work in Python 3.x". Applied timowcb's fix: sudo pip3 install cairocffi and importing it in the code got my problem fixed. After reading what you mentioned about the master branch being updated to fix this issue, I'm thinking it perhaps has to do with pip installing an older version from the package index, instead of the updated branch? Have no idea, anways got my problem solved so all is well I guess. |
I am using Matplotlib 1.5 and the problem still exist. Is Zenith-matic's approach using- "from cairocffi import * " the only approach, I thought Python 3.x is a stable platform and worth the upgrade?!
Warning (from warnings module): |
@snowman907 There exists 3 different Cairo wrappers for python. The 2 official ones py2cairo (python 2 only) and py3cairo (python 3) only. Unfortunately py3cairo does not implement For me the following works with cairocffi installed and fails when I uninstall it. import matplotlib
matplotlib.use('Gtk3Agg')
import matplotlib.pyplot as plt
plt.plot(range(100))
plt.show() Could you try running the following with python3.5 and paste the output? try:
import cairocffi as cairo
except ImportError:
try:
import cairo
except ImportError:
raise ImportError("Cairo backend requires that cairocffi or pycairo is installed.")
else:
HAS_CAIRO_CFFI = False
else:
HAS_CAIRO_CFFI = True
print(HAS_CAIRO_CFFI) |
Trying: returned : |
My first suggestion was NOT a suggestion it was an example of a pice of code that works with Which system are you using? On Ubuntu you should be able to install cairocffi with:
|
I did not understand from your example that is uses Cairocffi. sudo apt-get install python3-cairocffi Installed well and the above example worked well. The first example plotted well. The second example got TRUE. I am a bit surprise this problem is not more common/ better document on the web. Thanks for the fast response. On Thu, Nov 12, 2015 at 10:42 PM, Jens Hedegaard Nielsen <
Eyal Saiet Project manager Geophysical Institute |
The example
uses cairocffi if that is installed. If not it will use py2cairo on python2 and py3cairo on python3. Unfortunalty py3cairo does not currently work for the gtk3agg backend (it does work for the gtk3cairo backend) There might be a new release of py3cairo sometime in the future fixing this but my hopes are not high. We reported the issue to the py3cairo developers several years ago. |
Thanks, hope that will get a fix. |
When running the example from the Matplotlib website:
http://matplotlib.org/examples/user_interfaces/embedding_in_gtk3.html
on Ubuntu 14.04 (64 bit), I get the following error:
The text was updated successfully, but these errors were encountered: