Bug 1049624 - import of matplotlib.pyplot fails due to missing backend
Summary: import of matplotlib.pyplot fails due to missing backend
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-matplotlib
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Thomas Spura
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1046128 1050002 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-07 21:10 UTC by Jos de Kloe
Modified: 2014-02-22 00:39 UTC (History)
8 users (show)

Fixed In Version: python-matplotlib-1.3.1-3.fc20
Clone Of:
Environment:
Last Closed: 2014-02-22 00:39:35 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jos de Kloe 2014-01-07 21:10:14 UTC
Description of problem:

on a fresh Fedora 20 install, after installing matplotlib, I get an error when trying to import the matplotlib.pyplot subpackage

Version-Release number of selected component (if applicable):

python-matplotlib-1.3.0-1.fc20.x86_64.rpm

How reproducible:

allways

Steps to Reproduce:
1. install matplotlib on Fedora 20
2. Issue these commands on the python commandline:
>>> import matplotlib
>>> import matplotlib.pyplot

Actual results:

I get this error:
>>> import matplotlib
>>> import matplotlib.pyplot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 98, in \
<module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup\
()
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py", l\
ine 25, in pylab_setup
    globals(),locals(),[backend_name])
ImportError: No module named backend_qt4agg
>>>

Expected results:

matplotlib should install with at least one functioning backend and use that one as default.

Additional info:

Manually selecting the Agg backend still works fine:

>>> import matplotlib
>>> backend = 'Agg'
>>> matplotlib.use(backend)
>>> import matplotlib.pyplot

after installing the python-matplotlib-qt4 package the error disappears.

>>> import matplotlib
>>> import matplotlib.pyplot
>>> matplotlib.get_backend()
'Qt4Agg'

python-matplotlib-qt4 is an optional subpackage and not all users may have this one installed. So if this one indeed is the default backend I would suggest to make python-matplotlib-qt4 a requirement of python-matplotlib.

Also note that these bugs may point to related issues:
#1046128 IPython package should depend on python-matplotlib-qt4
and
#982793 - python3-matplotlib missing dependency on python3-matplotlib-tk

Comment 1 Paulo Andrade 2014-01-08 17:41:37 UTC
Upstream changed the default backend (checking 1.2 and 1.3 diffs):

-backend      : GTKAgg
+backend      : qt4agg

It could be patched to revert to use GTKAgg (or plain Agg) or
make a requires to python-matplotlib-qt4 in the main package.

Thomas (who did update to 1.3 :-), any comments?

Comment 2 Paulo Andrade 2014-01-08 17:44:37 UTC
*** Bug 1050002 has been marked as a duplicate of this bug. ***

Comment 3 Thomas Spura 2014-01-25 15:57:43 UTC
(In reply to Paulo Andrade from comment #1)
> Thomas (who did update to 1.3 :-), any comments?

GTKAgg will be used now again (without any further comment) :)

Comment 4 Thomas Spura 2014-01-25 17:26:04 UTC
*** Bug 1046128 has been marked as a duplicate of this bug. ***

Comment 5 Paulo Andrade 2014-01-31 15:45:58 UTC
It does not work out of the box for python3, as reported in
feedback to my update (TkAgg works).
How to fix it?

Traceback (most recent call last):
  File "/usr/lib64/python3.3/site-packages/matplotlib/backends/backend_gtk.py", line 12, in <module>
    import gobject
ImportError: No module named 'gobject'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.3/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib64/python3.3/site-packages/matplotlib/pylab.py", line 269, in <module>
    from matplotlib.pyplot import *
  File "/usr/lib64/python3.3/site-packages/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/usr/lib64/python3.3/site-packages/matplotlib/backends/__init__.py", line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/usr/lib64/python3.3/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
    from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
  File "/usr/lib64/python3.3/site-packages/matplotlib/backends/backend_gtk.py", line 16, in <module>
    raise ImportError("Gtk* backend requires pygtk to be installed.")
ImportError: Gtk* backend requires pygtk to be installed.

Comment 6 Eric Work 2014-02-07 05:12:16 UTC
I'm getting the same error as comment #5.  I'm not even sure how to fix this other than switching back to the Qt4 backend.  I don't see any combination of packages I don't already have installed or could install to fix this problem.

Comment 7 Jos de Kloe 2014-02-07 09:49:56 UTC
I can confirm the problem on my side as well. After upgrading  python3-matplotlib.x86_64 from version 0:1.3.0-1.fc20 to 0:1.3.1-2.fc20 I get the following output:

>>> import matplotlib
>>> import matplotlib.pyplot
Traceback (most recent call last):
  File "/usr/lib64/python3.3/site-packages/matplotlib/backends/backend_gtk.py", line 12, in <module>
    import gobject
ImportError: No module named 'gobject'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.3/site-packages/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/usr/lib64/python3.3/site-packages/matplotlib/backends/__init__.py", line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/usr/lib64/python3.3/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
    from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
  File "/usr/lib64/python3.3/site-packages/matplotlib/backends/backend_gtk.py", line 16, in <module>
    raise ImportError("Gtk* backend requires pygtk to be installed.")
ImportError: Gtk* backend requires pygtk to be installed.
>>> matplotlib.get_backend()
'GTKAgg'
>>> 

Manually choosing 'Agg' as backend does provide a workaround, but is not an option for interactive use.

This was a nice opportunity to test the full list of backends, just out of curiosity. I just tried all options that you see in the error message when you try to set an unknown backend:
 ['pdf', 'gdk', 'CocoaAgg', 'emf', 'WebAgg', 'WX', 'pgf', 'GTK3Agg',
  'TkAgg', 'GTK', 'Qt4Agg', 'GTKCairo', 'GTKAgg', 'ps', 'WXAgg',
  'template', 'agg', 'GTK3Cairo', 'cairo', 'MacOSX', 'svg']

My test results:

pdf: works
gdk: gives error: ImportError: No module named 'gobject'
CocoaAgg: gives error: ImportError: The CococaAgg backend required PyObjC to be installed!
emf: gives error: ImportError: No module named 'matplotlib.backends.backend_emf'
WebAgg: gives error: RuntimeError: The WebAgg backend requires Tornado.
WX: gives error: ImportError: Matplotlib backend_wx and backend_wxagg require wxversion, which was not found.
pgf: gives error: FileNotFoundError: [Errno 2] No such file or directory: 'xelatex'
GTK3Agg: gives error: warnings.warn("The Gtk3Agg backend is not known to work on Python 3.x."); Error in atexit._run_exitfuncs: AttributeError: 'FigureManagerGTK3Agg' object has no attribute 'canvas'
TkAgg: gives error: ImportError: No module named 'matplotlib.backends.backend_tkagg (but works after manually installing python3-matplotlib-tk)
GTK: gives error: ImportError: Gtk* backend requires pygtk to be installed (but no python3 version of pygtk is currently available!)
Qt4Agg: gives error: ImportError: No module named 'matplotlib.backends.backend_qt4agg' (but works after manually installing python3-matplotlib-qt4)
GTKCairo: gives error: ImportError: No module named 'gtk'
GTKAgg: gives error: ImportError: Gtk* backend requires pygtk to be installed.
ps: works
WXAgg: gives error: ImportError: Matplotlib backend_wx and backend_wxagg require wxversion, which was not found.
template: works
agg: works
GTK3Cairo: gives error: Error in atexit._run_exitfuncs: AttributeError: 'FigureManagerGTK3Cairo' object has no attribute 'canvas'
cairo: works
MacOSX: [not available on linux]
svg: works

So concluding: only some "non-GUI backends" are working out of the box.

However, after manually installing python3-matplotlib-qt4 and python3-matplotlib-tk these backends do work.

This I found rather weird, since I thought they where pulled in as dependency, so I checked my yum output again. It says:

Updating:
 python3-matplotlib                                x86_64                      1.3.1-2.fc20                        updates                       30 M
Installing for dependencies:
 python-matplotlib-data                            noarch                      1.3.1-2.fc20                        updates                      2.1 M
 python-matplotlib-data-fonts                      noarch                      1.3.1-2.fc20                        updates                      985 k
Updating for dependencies:
 python-matplotlib                                 x86_64                      1.3.1-2.fc20                        updates                       30 M
 python-matplotlib-doc                             x86_64                      1.3.1-2.fc20                        updates                      106 M
 python-matplotlib-qt4                             x86_64                      1.3.1-2.fc20                        updates                       36 k
 python-matplotlib-tk                              x86_64                      1.3.1-2.fc20                        updates                       74 k
 python-matplotlib-wx                              x86_64                      1.3.1-2.fc20                        updates                       57 k

So this reveils the actual problem: 
python3-matplotlib is pulling in the python2 versions of python-matplotlib-qt4, python-matplotlib-tk and python-matplotlib-wx, which obviously do not provide the needed functionality for the python3 matplotlib.

So something seems confused in the requirements defined on python3-matplotlib (or the handling of these requirements).

Comment 8 Fedora Update System 2014-02-11 16:20:06 UTC
python-matplotlib-1.3.1-3.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/python-matplotlib-1.3.1-3.fc20

Comment 9 Fedora Update System 2014-02-12 14:39:14 UTC
Package python-matplotlib-1.3.1-3.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python-matplotlib-1.3.1-3.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-2352/python-matplotlib-1.3.1-3.fc20
then log in and leave karma (feedback).

Comment 10 Fedora Update System 2014-02-22 00:39:35 UTC
python-matplotlib-1.3.1-3.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.