Bug 1401267

Summary: Matplotlib is outdated and broken on Qt5
Product: [Fedora] Fedora Reporter: Elliott Sales de Andrade <quantum.analyst>
Component: python-matplotlibAssignee: Thomas Spura <tomspur>
Status: CLOSED WORKSFORME QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 28CC: cstratak, dominik, extras-qa, gwync, jonathan.underwood, jspaleta, lbalhar, mhroncok, paul.destefano-redhat2, paulo.cesar.pereira.de.andrade, pviktori, python-sig, tomspur
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-05-18 09:46:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
expected pdf
none
created pdf none

Description Elliott Sales de Andrade 2016-12-04 07:12:12 UTC
Description of problem:
Both Fedora 24 and 25 have matplotlib 1.5.2-rc2, but 1.5.3 is available. Additionally, that release does not work on Qt5.7, which is now available in Fedora 25 (see [1] below.)

Version-Release number of selected component (if applicable):
python2-matplotlib-1.5.2-0.2.rc2.fc25.x86_64
python3-matplotlib-1.5.2-0.2.rc2.fc25.x86_64


Steps to Reproduce:
1. Set backend to Qt5Agg
2. Create and show a figure


Actual results:
A Qt5 exception is raised:
QObject::connect: Cannot connect NavigationToolbar2QT::message(QString) to (null)::_show_message()
Traceback (most recent call last):
  File "examples/pylab_examples/text_rotation_relative_to_line.py", line 17, in <module>
    h = plt.plot(np.arange(0, 10), np.arange(0, 10))
  File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 3146, in plot
    ax = gca()
  File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 928, in gca
    return gcf().gca(**kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 578, in gcf
    return figure()
  File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 527, in figure
    **kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 43, in new_figure_manager
    return new_figure_manager_given_figure(num, thisFig)
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 51, in new_figure_manager_given_figure
    return FigureManagerQT(canvas, num)
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 465, in __init__
    self.toolbar.message.connect(self._show_message)
TypeError: connect() failed between NavigationToolbar2QT.message[str] and _show_message()


Additional info:
[1] https://github.com/matplotlib/matplotlib/pull/6854

Comment 1 Thomas Spura 2016-12-04 19:02:43 UTC
I'm currently hitting a failure with 1.5.3:
FAIL: matplotlib.tests.test_mathtext.test_mathtext_stixsans_52.test
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "BUILDROOT/python-matplotlib-1.5.3-1.fc25.x86_64/usr/lib64/python2.7/site-packages/matplotlib/testing/decorators.py", line 53, in failer
    result = f(*args, **kwargs)
  File "BUILDROOT/python-matplotlib-1.5.3-1.fc25.x86_64/usr/lib64/python2.7/site-packages/matplotlib/testing/decorators.py", line 220, in do_test
    '(RMS %(rms).3f)'%err)
ImageComparisonFailure: images not close: matplotlib-1.5.3/result_images/test_mathtext/mathtext_stixsans_52_pdf.png vs. matplotlib-1.5.3/result_images/test_mathtext/mathtext_stixsans_52-expected_pdf.png (RMS 32.325)

Comment 2 Elliott Sales de Andrade 2016-12-05 02:48:30 UTC
Might be a transient failure, but that's a pretty high RMS. Can you post the resultant PDF?

Comment 3 Thomas Spura 2016-12-05 19:52:23 UTC
Created attachment 1228147 [details]
expected pdf

Comment 4 Thomas Spura 2016-12-05 19:52:51 UTC
Created attachment 1228148 [details]
created pdf

Comment 5 Thomas Spura 2016-12-05 19:57:13 UTC
It seems the created font is a bit wider than expected. I think it might be ignoreable by visual inspection, but not by judging on the RMS...

Comment 6 Elliott Sales de Andrade 2016-12-07 06:52:11 UTC
How do the PDFs look? I guess they wouldn't be much different from the PNGs, but you never know.

Does it happen if you run it again? Could be a transient bug (which is unfortunate.) Or maybe it's a different version of Stix that's causing it?

Comment 7 Elliott Sales de Andrade 2017-03-27 07:20:08 UTC
This is a known bug [1]; just restart the build for now.

[1] https://github.com/matplotlib/matplotlib/issues/7911

Comment 8 Paul DeStefano 2017-04-24 00:19:05 UTC
So, I see this when I try to switch to Qt5Agg backend.  But, GTKAgg also gives an error, 

Traceback (most recent call last):
  File "/usr/lib64/python3.5/site-packages/matplotlib/backends/backend_gtk.py", line 15, in <module>
    import gobject
ImportError: No module named 'gobject'
...
ImportError: Gtk* backend requires pygtk to be installed.

but, pygtk2 is installed.

Finally, the default backend seems to be 'agg', and, while this doesn't produce any errors, it also doesn't produce any plot windows.  I cannot get python2, python3, ipython2, or ipython3, to show any plots.  I can make figures and savefig(), but I cannot show() any figures.

Are these all related?

Comment 9 Elliott Sales de Andrade 2017-04-24 00:22:06 UTC
Better to use the GTK3Agg backend than the GTKAgg backend; the latter is unsupported and outdated. You should be able to use the TkAgg backend from the existing package. (Note, both of these are in separate Fedora packages.)

Comment 10 Paul DeStefano 2017-05-07 18:19:08 UTC
Thanks, okay.  I did get TkAgg to work.

Any idea why it will not select a working backend automatically.  It always worked before without me fiddling with the backend choice.

Comment 11 Elliott Sales de Andrade 2017-05-08 00:06:54 UTC
I don't understand; in your previous comment, you said you were trying to change the backend _on purpose_.

Comment 12 Paul DeStefano 2017-05-08 00:26:35 UTC
Sorry, I actually just reported three symptoms as I didn't know if my problem was related to this bug or not.  I didn't mean to suggest a particular scenario.

What happened was I tried select Qt5Agg only after I found the default, 'agg', didn't work at all.  Qt5Agg gave me an error, which lead me to this bug.  But, since 'agg' didn't produce an error, I didn't really have much to go on, so I figured a good start would be to suggest the two might be related and see what you would think about that.

Sounds like they are not related.  I should probably open a new bug.  But, let me know if you recognize this problem with 'agg'.  Also, let me know if I should report upstream, instead of Fedora.

Thanks for your help and for not just ignoring my tangential question.

Comment 13 Elliott Sales de Andrade 2017-07-10 08:03:29 UTC
Agg is non-interactive; it's working as intended, though it should not be the default.

Comment 14 Paul DeStefano 2017-07-11 04:54:04 UTC
Thanks for you help!

What can I try?  What could cause Agg to be the default?  I thought it could be that Qt isn't working and mpl falls back to Agg because of these other backend problems.  Willing to do whatever testing you want.

Do you think this is related or a different bug?  This is really annoying as you can imagine since it's not possible to switch backend after trying to plot and only then do I realize it's not working.

Comment 15 Fedora End Of Life 2017-11-16 19:47:41 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 16 Fedora End Of Life 2017-12-12 10:56:05 UTC
Fedora 25 changed to end-of-life (EOL) status on 2017-12-12. Fedora 25 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 17 Paul DeStefano 2017-12-17 21:04:07 UTC
This should not be closed, as far as I can tell.  Python defaults still don't show plots.

Comment 18 Dominik 'Rathann' Mierzejewski 2017-12-20 18:58:54 UTC
Reopening, then.

Comment 19 Dominik 'Rathann' Mierzejewski 2017-12-20 19:00:47 UTC
(In reply to Paul DeStefano from comment #8)
> So, I see this when I try to switch to Qt5Agg backend.  But, GTKAgg also
> gives an error, 
> 
> Traceback (most recent call last):
>   File
> "/usr/lib64/python3.5/site-packages/matplotlib/backends/backend_gtk.py",
> line 15, in <module>
>     import gobject
> ImportError: No module named 'gobject'
> ...
> ImportError: Gtk* backend requires pygtk to be installed.
> 
> but, pygtk2 is installed.
> 
> Finally, the default backend seems to be 'agg', and, while this doesn't
> produce any errors, it also doesn't produce any plot windows.  I cannot get
> python2, python3, ipython2, or ipython3, to show any plots.  I can make
> figures and savefig(), but I cannot show() any figures.
> 
> Are these all related?

I can reproduce this in python3 shell:
$ python3
Python 3.6.3 (default, Oct  9 2017, 12:07:10) 
[GCC 7.2.1 20170915 (Red Hat 7.2.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gobject
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gobject'

However, if I import gi first, it works:
$ python3
Python 3.6.3 (default, Oct  9 2017, 12:07:10) 
[GCC 7.2.1 20170915 (Red Hat 7.2.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> import gobject
>>> 

Could someone try patching backend_gtk.py to import gi before gobject?

Comment 20 Fedora End Of Life 2018-02-20 15:36:42 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 28 development cycle.
Changing version to '28'.

Comment 21 Paul DeStefano 2018-05-15 09:28:09 UTC
It is very difficult to collaborate on Phython code that uses MPL since the defaults are completely broken on Fedora and no one else likes TkAgg but that is the only logical next choice.

What is the status of this very old issue?

Comment 22 Lumír Balhar 2018-05-16 13:01:31 UTC
I really don't understand what is a problem here. I've tried to reproduce a quite similar issue in the bug 1526834 [0] but from my point of view, it seems that the default backend for matplotlib is correctly set to TkAgg and if you want you can simply install qt5 backed and set it as default via an environment variable (for example). I've tried also GTK3Agg backend and it works as well.

Could you please try to reproduce the issue again with the latest matplotlib?

[0] https://bugzilla.redhat.com/show_bug.cgi?id=1526834

Comment 23 Paul DeStefano 2018-05-16 16:01:58 UTC
Sorry, I think I got this confused with the other bug.  I don't know what is wrong with Qt5Agg any more.  It works on my system.

Comment 24 Lumír Balhar 2018-05-17 20:59:45 UTC
Ok, adding needinfo flag for more information.

Comment 25 Paul DeStefano 2018-05-18 00:21:11 UTC
No, not me.  I'm okay, now.  I think you can close it.