Bug 1526834 - default backend is 'agg' but shouldn't be, started two Fedora releases ago
Summary: default backend is 'agg' but shouldn't be, started two Fedora releases ago
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: python-matplotlib
Version: 28
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lumír Balhar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-17 21:18 UTC by Paul DeStefano
Modified: 2018-05-22 09:27 UTC (History)
12 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2018-05-22 09:27:58 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Paul DeStefano 2017-12-17 21:18:06 UTC
Description of problem:
Since Fedora25, 'agg' is the default backend on my system.  Why is that?

According to comments on bug 1401267, this is incorrect, but I don't know how to fix it.

Version-Release number of selected component (if applicable):
python3-matplotlib-2.0.0-3.fc27.x86_64

How reproducible:
Since Fedora 25

Steps to Reproduce:
1. python3
2. import matplotlib as plt
3. print(plt.get_backend())

Actual results:
'agg'

Expected results:
not 'agg'

Additional info:
Has this been fixed, upstream?
https://github.com/matplotlib/matplotlib/issues/7874/

Comment 1 Paul DeStefano 2018-05-15 09:29:03 UTC
Another fedora release passes.  I don't understand why this has not been fixed.

Comment 2 Miro Hrončok 2018-05-15 10:46:07 UTC
Thomas is not very active in Fedora those days.

Lumír, you would be my first choice for "science" Python issues. Can you please look at this?

Comment 3 Lumír Balhar 2018-05-16 12:47:07 UTC
Hello.

I cannot reproduce the issue. Could you please try it again with the latest version of matplotlib?

I have python3-matplotlib version 2.2.2-1.fc28 which has TkAgg as a default backend. AFAIK the backend should be chosen automatically when it's available and python3-matplotlib-tk is installed as a dependency automatically so TkAgg should be used.

I've tried also 'Qt5Agg' backend. First, I've installed python3-matplotlib-qt5 package which doesn't change default backend so I've had to set it manually (via an environment variable).

From my point of view, everything works as expected. I've tested that on my laptop with Fedora 28 and also in a Docker container with Fedora 27.

How can I reproduce your issue?

Have a nice day.

Comment 4 Paul DeStefano 2018-05-16 17:01:04 UTC
Interesting, it occurs on my system.

$ rpm --query python3-matplotlib-tk
python3-matplotlib-tk-2.2.2-1.fc28.x86_64

$ python3
Python 3.6.5 (default, Mar 29 2018, 18:20:46)
[GCC 8.0.1 20180317 (Red Hat 8.0.1-0.19)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> print(plt.get_backend())
agg

On a VM, however, I see the expected behavior.  Sorry.

Do you have any idea how I can figure out what is wrong?  I've checked for old python packages, and that doesn't seem to be it.

I tried loading with verbose flag; here's what I see on my system:
>>> import matplotlib.pyplot as plt
...
import 'matplotlib.figure'
# <_frozen_importlib_external.SourceFileLoader object at 0x7efc2301f2e8>
# /usr/lib64/python3.6/site-packages/matplotlib/backends/__pycache__/__init__.cpython-36.pyc matches /usr/lib64/python3.6/site-packages/matplotlib/backends/__init__.py
# code object from '/usr/lib64/python3.6/site-packages/matplotlib/backends/__pycache__/__init__.cpython-36.pyc'
import 'matplotlib.backends' # <_frozen_importlib_external.SourceFileLoader object at 0x7efc2159aef0>
# /usr/lib64/python3.6/site-packages/matplotlib/backends/__pycache__/backend_agg.cpython-36.pyc matches /usr/lib64/python3.6/site-packages/matplotlib/backends/backend_agg.py
# code object from '/usr/lib64/python3.6/site-packages/matplotlib/backends/__pycache__/backend_agg.cpython-36.pyc'
# extension module 'matplotlib.backends._backend_agg' loaded from '/usr/lib64/python3.6/site-packages/matplotlib/backends/_backend_agg.cpython-36m-x86_64-linux-gnu.so'
# extension module 'matplotlib.backends._backend_agg' executed from '/usr/lib64/python3.6/site-packages/matplotlib/backends/_backend_agg.cpython-36m-x86_64-linux-gnu.so'
import 'matplotlib.backends._backend_agg' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7efc214d5c50>
import 'matplotlib.backends.backend_agg' # <_frozen_importlib_external.SourceFileLoader object at 0x7efc214e55f8>
import 'matplotlib.pyplot' # <_frozen_importlib_external.SourceFileLoader object at 0x7efc555870f0>
>>>

It looks like MPL finds and loads 'agg' first thing.  Do you know what is supposed to happen here?

Here's what I see on the VM:
>>> import matplotlib.pyplot as plt
...
import 'matplotlib.backends'
# <_frozen_importlib_external.SourceFileLoader object at 0x7fd53ed60a20>
# /usr/lib64/python3.6/site-packages/matplotlib/backends/__pycache__/backend_tkagg.cpython-36.pyc matches /usr/lib64/python3.6/site-packages/matplotlib/backends/backend_tkagg.py
# code object from '/usr/lib64/python3.6/site-packages/matplotlib/backends/__pycache__/backend_tkagg.cpython-36.pyc'
# /usr/lib64/python3.6/site-packages/matplotlib/backends/__pycache__/tkagg.cpython-36.pyc matches /usr/lib64/python3.6/site-packages/matplotlib/backends/tkagg.py
# code object from '/usr/lib64/python3.6/site-packages/matplotlib/backends/__pycache__/tkagg.cpython-36.pyc'
# /usr/lib64/python3.6/tkinter/__pycache__/__init__.cpython-36.pyc matches /usr/lib64/python3.6/tkinter/__init__.py
# code object from '/usr/lib64/python3.6/tkinter/__pycache__/__init__.cpython-36.pyc'
# extension module '_tkinter' loaded from '/usr/lib64/python3.6/lib-dynload/_tkinter.cpython-36m-x86_64-linux-gnu.so'
# extension module '_tkinter' executed from '/usr/lib64/python3.6/lib-dynload/_tkinter.cpython-36m-x86_64-linux-gnu.so'
...

Comment 5 Paul DeStefano 2018-05-21 04:41:15 UTC
Argh!  MPL *skips* the systemwide defaults (/etc/matplotlibc) if it finds a user-specific matplotlibrc?  That's what happened.  I set a few personal things in my user matplotlibrc, but not the backend.  When I removed my customization, TkAgg was selected again.  A tough lesson.

This bug has been accepted upstream.
https://github.com/matplotlib/matplotlib/issues/6320

Comment 6 Petr Viktorin (pviktori) 2018-05-22 09:27:58 UTC
Upstream plans to fix this:
    https://github.com/matplotlib/matplotlib/issues/11279
    https://github.com/matplotlib/matplotlib/pull/9528

Anyone interested in helping out should get involved there. Once it's fixed upstream, Fedora should pick up the change in the usual way.


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