Skip to content

[Bug]: Intermittent failure on GitHub Windows runner: _tkinter.TclError: invalid command name "tcl_findLibrary" #29119

@DanielYang59

Description

@DanielYang59

Bug summary

We are seeing the following intermittent failure on GitHub Windows runner:
_tkinter.TclError: invalid command name "tcl_findLibrary"

Code for reproduction

Sadly, I cannot reproduce this locally, the failure seems to be emitted by:
plt.figure(figsize=(width, height), facecolor="w", dpi=dpi)

From the following function:

mod = importlib.import_module(f"palettable.colorbrewer.{color_cycle[0]}")
colors = getattr(mod, color_cycle[1]).mpl_colors
from cycler import cycler

plt.figure(figsize=(width, height), facecolor="w", dpi=dpi)
ax = plt.gca()

Actual outcome

tests\analysis\test_pourbaix_diagram.py:305: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src\pymatgen\analysis\pourbaix_diagram.py:975: in get_pourbaix_plot
    ax = ax or pretty_plot(16)
src\pymatgen\util\plotting.py:61: in pretty_plot
    plt.figure(figsize=(width, height), facecolor="w", dpi=dpi)
C:\Users\runneradmin\micromamba\envs\pmg\lib\site-packages\matplotlib\pyplot.py:1027: in figure
    manager = new_figure_manager(
C:\Users\runneradmin\micromamba\envs\pmg\lib\site-packages\matplotlib\pyplot.py:550: in new_figure_manager
    return _get_backend_mod().new_figure_manager(*args, **kwargs)
C:\Users\runneradmin\micromamba\envs\pmg\lib\site-packages\matplotlib\backend_bases.py:3507: in new_figure_manager
    return cls.new_figure_manager_given_figure(num, fig)
C:\Users\runneradmin\micromamba\envs\pmg\lib\site-packages\matplotlib\backend_bases.py:3512: in new_figure_manager_given_figure
    return cls.FigureCanvas.new_manager(figure, num)
C:\Users\runneradmin\micromamba\envs\pmg\lib\site-packages\matplotlib\backend_bases.py:1797: in new_manager
    return cls.manager_class.create_with_canvas(cls, figure, num)
C:\Users\runneradmin\micromamba\envs\pmg\lib\site-packages\matplotlib\backends\_backend_tk.py:483: in create_with_canvas
    window = tk.Tk(className="matplotlib")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tkinter.Tk object .>, screenName = None, baseName = 'pytest'
className = 'matplotlib', useTk = True, sync = False, use = None

    def __init__(self, screenName=None, baseName=None, className='Tk',
                 useTk=True, sync=False, use=None):
        """Return a new top level widget on screen SCREENNAME. A new Tcl interpreter will
        be created. BASENAME will be used for the identification of the profile file (see
        readprofile).
        It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
        is the name of the widget class."""
        self.master = None
        self.children = {}
        self._tkloaded = False
        # to avoid recursions in the getattr code in case of failure, we
        # ensure that self.tk is always _something_.
        self.tk = None
        if baseName is None:
            import os
            baseName = os.path.basename(sys.argv[0])
            baseName, ext = os.path.splitext(baseName)
            if ext not in ('.py', '.pyc'):
                baseName = baseName + ext
        interactive = False
>       self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
E       _tkinter.TclError: invalid command name "tcl_findLibrary"

Expected outcome

No error should be raised

Additional information

This error seems pretty intermittent, cannot reproduce it reliably. I'm not entirely sure what is causing this, is this a GitHub runner bug, windows bug or matplotlib issue?

Operating system

GitHub windows-latest runner

Matplotlib Version

3.9.2

Matplotlib Backend

No response

Python version

3.10.15

Installation

pip (uv in fact)

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