-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
'MPLBACKEND=webagg' is overwritten by agg when $DISPLAY is not set on Linux #14903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That is definitely a bug in the fallback logic to make sure we don't try to use a GUI backend on a headless server. I suspect we have miss-categorized |
Thanks for your reply! |
The short term fix is to add webagg to https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/rcsetup.py#L44. The long term fix is... we need to figure out what rcParams["backend_fallback"] really means. I have a PR that fixes that, but runs into other inconsistencies :( |
Is the fallback behavior really needed even when users explicitly set the backend by MPLBACKEND or matplotlibrc? |
this was requested many times when the fallback was not present (you can search the issue tracker), so heh. |
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 matplotlib#14903
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 matplotlib#14903
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 matplotlib#14903
Thanks for your work! |
Bug report
MPLBACKEND=webagg
is overwritten by 'agg' when $DISPLAY is not set on Linux.backend:webagg
written in matplotlibrc was as same asMPLBACKEND=webagg
(I tried).Code for reproduction
Actual outcome
When I type the shell command
MPLBACKEND=WebAgg DISPLAY= python test.py
,the backend is overwritten by agg.
When I type the shell command
MPLBACKEND=WebAgg DISPLAY=:0 python test.py
(although X11 is not installed),I can use webagg.
Expected outcome
When I type the shell command
MPLBACKEND=WebAgg DISPLAY= python test.py
,Question
Does matplotlib overwrite the backend by 'agg', when
$DISPLAY
is empty?I understand that the fallback behavior is useful.
However, is there any reason that webagg must be fallbacked to agg?
Or, is there a correct way (not setting the
$DISPLAY
) to avoid the fallback behavior?Matplotlib version
The text was updated successfully, but these errors were encountered: