Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 699ecad

Browse files
committed
FIX: do not consider webagg and nbagg "interactive" for fallback
There is logic in pyplot to determine if the user has is some way selected a backend which is incompatible with the interactive framework that we detect is running. This helps prevent issues where the user is already using one GUI frame work (ex tk) before Matplotlib is imported and has Matplotlib configured to use Qt. The other place this behavior is desired is if Matplotlib is configured to use a GUI framework by default, but is then imported on a headless server. By detecting there is no DISPLAY we fall back to Agg rather than failing to import. From the point of view of having UI events, webagg and nbagg are interactive backends, however from the point of view of requiring DISPLAY they are not. This is the minimal fix, filtering out these two backends in pyplot rather than changing this in rcsetup, incase anyone is relying on those lists for other purposes. closes #14903
1 parent 09c8381 commit 699ecad

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/matplotlib/pyplot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,8 @@ def getname_val(identifier):
22472247
# requested, ignore rcParams['backend'] and force selection of a backend that
22482248
# is compatible with the current running interactive framework.
22492249
if (rcParams["backend_fallback"]
2250-
and dict.__getitem__(rcParams, "backend") in _interactive_bk
2250+
and dict.__getitem__(rcParams, "backend") in [
2251+
k for k in _interactive_bk if k not in ['WebAgg', 'nbAgg']]
22512252
and cbook._get_running_interactive_framework()):
22522253
dict.__setitem__(rcParams, "backend", rcsetup._auto_backend_sentinel)
22532254
# Set up the backend.

0 commit comments

Comments
 (0)