X Tutup
Skip to content

Cannot Disable TkAgg Backend #7526

@git-blame

Description

@git-blame

Setup:

Matplotlib version 1.5.3 on FreeBSD 11 installed with pip

Problem:

I want to use matplotlib with only non-GUI backend AGG but it always installs with at least tkagg. This leads to problems when matplotlib cannot import _tkinter. I have created my own setup.cfg file and explicitly disabled all GUI backends including tkagg but matplotlib will still install tkagg. Note that the matplotlib setup.cfg documentation states that all GUI backends can be turned off.

env MPLSETUPCFG=./setup.cfg pip install matplotlib
...
    OPTIONAL BACKEND EXTENSIONS
                    macosx: no  [skipping due to configuration]
                    qt5agg: no  [skipping due to configuration]
                    qt4agg: no  [skipping due to configuration]
                   gtk3agg: no  [skipping due to configuration]
                 gtk3cairo: no  [skipping due to configuration]
                    gtkagg: no  [skipping due to configuration]
                     tkagg: yes [installing; run-time loading from Python Tcl /
                            Tk]
                     wxagg: no  [skipping due to configuration]
                       gtk: no  [skipping due to configuration]
                       agg: yes [installing]
                     cairo: no  [skipping due to configuration]
                 windowing: no  [skipping due to configuration]

Workaround:

Explicitly specify matplotlib.use("Agg") in code.

Root Cause?

In file setupext.py, the subclass BackendTkAgg overrides the check() method. This means tkagg never checks the configuration file (this behaviour is normally inherited from the original check()). Note the other GUI backend classes implement the check_requirements() method.

class BackendTkAgg(OptionalBackendPackage):
    name = "tkagg"
    force = True

    def check(self):
        return "installing; run-time loading from Python Tcl / Tk"

Is this a bug or is tkagg a required dependency?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup