Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Milestone
Description
Bug summary
Hi,
We are updating matplotlib version from 3.8.3 to 3.10.0 and in the process, we see failures of the kind:
47s E ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running
An example log is here:https://ci.debian.net/packages/g/gudhi/unstable/amd64/58337026/
This was working fine with matplotlib 3.8.3 version. The tests are running in a lxc container, AFAICS.
Code for reproduction
Failurelog:t=Tomato(metric="euclidean",graph_type="radius",r=4.7,k=4)81047st.fit(a)81147sassertt.max_weight_per_cc_.size==281247sassertt.neighbors_== [[0,1,2], [0,1,2], [0,1,2], [3,4,5,6], [3,4,5], [3,4,5], [3,6]]81347s>t.plot_diagram()81447s81547stest/test_tomato.py:41:81647s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _81747s/usr/lib/python3/dist-packages/gudhi/clustering/tomato.py:288:inplot_diagram81847splt.plot([l,r], [l,r])81947s/usr/lib/python3/dist-packages/matplotlib/pyplot.py:3829:inplot82047sreturngca().plot(82147s/usr/lib/python3/dist-packages/matplotlib/pyplot.py:2776:ingca82247sreturngcf().gca()82347s/usr/lib/python3/dist-packages/matplotlib/pyplot.py:1108:ingcf82447sreturnfigure()82547s/usr/lib/python3/dist-packages/matplotlib/pyplot.py:1042:infigure82647smanager=new_figure_manager(82747s/usr/lib/python3/dist-packages/matplotlib/pyplot.py:551:innew_figure_manager82847s_warn_if_gui_out_of_main_thread()82947s/usr/lib/python3/dist-packages/matplotlib/pyplot.py:528:in_warn_if_gui_out_of_main_thread83047scanvas_class=cast(type[FigureCanvasBase],_get_backend_mod().FigureCanvas)83147s/usr/lib/python3/dist-packages/matplotlib/pyplot.py:369:in_get_backend_mod83247sswitch_backend(rcParams._get("backend"))83347s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _83447s83547snewbackend='TkAgg'83647s83747sdefswitch_backend(newbackend:str)->None:83847s"""839 47s Set the pyplot backend.840 47s841 47s Switching to an interactive backend is possible only if no event loop for842 47s another interactive backend has started. Switching to and from843 47s non-interactive backends is always possible.844 47s845 47s If the new backend is different than the current backend then all open846 47s Figures will be closed via ``plt.close('all')``.847 47s848 47s Parameters849 47s ----------850 47s newbackend : str851 47s The case-insensitive name of the backend to use.852 47s853 47s """85447sglobal_backend_mod85547s# make sure the init is pulled up so we can assign to it later85647simportmatplotlib.backends85747s85847sifnewbackendisrcsetup._auto_backend_sentinel:85947scurrent_framework=cbook._get_running_interactive_framework()86047s86147sif (current_frameworkand86247s (backend:=backend_registry.backend_for_gui_framework(86347scurrent_framework))):86447scandidates= [backend]86547selse:86647scandidates= []86747scandidates+= [86847s"macosx","qtagg","gtk4agg","gtk3agg","tkagg","wxagg"]86947s87047s# Don't try to fallback on the cairo-based backends as they each have87147s# an additional dependency (pycairo) over the agg-based backend, and87247s# are of worse quality.87347sforcandidateincandidates:87447stry:87547sswitch_backend(candidate)87647sexceptImportError:87747scontinue87847selse:87947srcParamsOrig['backend']=candidate88047sreturn88147selse:88247s# Switching to Agg should always succeed; if it doesn't, let the88347s# exception propagate out.88447sswitch_backend("agg")88547srcParamsOrig["backend"]="agg"88647sreturn88747sold_backend=rcParams._get('backend')# get without triggering backend resolution88847s88947smodule=backend_registry.load_backend_module(newbackend)89047scanvas_class=module.FigureCanvas89147s89247srequired_framework=canvas_class.required_interactive_framework89347sifrequired_frameworkisnotNone:89447scurrent_framework=cbook._get_running_interactive_framework()89547sif (current_frameworkandrequired_framework89647sandcurrent_framework!=required_framework):89747s>raiseImportError(89847s"Cannot load backend {!r} which requires the {!r} interactive "89947s"framework, as {!r} is currently running".format(90047snewbackend,required_framework,current_framework))90147sEImportError:Cannotloadbackend'TkAgg'whichrequiresthe'tk'interactiveframework,as'headless'iscurrentlyrunning90247s
Actual outcome
Failing inside the container
Expected outcome
Passing inside the container
Additional information
No response
Operating system
Debian Unstable
Matplotlib Version
3.10.0
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None
Metadata
Metadata
Assignees
Labels
No labels