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

Skip to content

Commit a4ffb68

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 7f171d6 commit a4ffb68

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
@@ -2244,7 +2244,8 @@ def getname_val(identifier):
22442244
# requested, ignore rcParams['backend'] and force selection of a backend that
22452245
# is compatible with the current running interactive framework.
22462246
if (rcParams["backend_fallback"]
2247-
and dict.__getitem__(rcParams, "backend") in _interactive_bk
2247+
and dict.__getitem__(rcParams, "backend") in [
2248+
k for k in _interactive_bk if k not in ['WebAgg', 'nbAgg']]
22482249
and cbook._get_running_interactive_framework()):
22492250
dict.__setitem__(rcParams, "backend", rcsetup._auto_backend_sentinel)
22502251
# Set up the backend.

0 commit comments

Comments
 (0)