Skip to content

ValueError: Key backend: '' is not a valid value for backend #19848

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

Closed
pllim opened this issue Apr 1, 2021 · 8 comments · Fixed by #19855
Closed

ValueError: Key backend: '' is not a valid value for backend #19848

pllim opened this issue Apr 1, 2021 · 8 comments · Fixed by #19855
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@pllim
Copy link

pllim commented Apr 1, 2021

Bug report

I am actually not sure if this is a bug. It started happening today for matplotlib installed from your master branch for our CI. We run some image tests using your dev version on CircleCI, which uses our tox.ini and some settings in astropy/conftest.py.

It starts to complain about no backend even though we set it at astropy/conftest.py#L84 and that works for older versions of matplotlib.

INTERNALERROR>   File ".../matplotlib/__init__.py", line 843, in <module>
INTERNALERROR>     fail_on_error=True)
INTERNALERROR>   File ".../matplotlib/__init__.py", line 773, in _rc_params_in_file
INTERNALERROR>     config[key] = val  # try to convert to proper type or raise
INTERNALERROR>   File ".../matplotlib/__init__.py", line 607, in __setitem__
INTERNALERROR>     raise ValueError(f"Key {key}: {ve}") from None
INTERNALERROR> ValueError: Key backend: '' is not a valid value for backend; supported values are
['GTK3Agg', 'GTK3Cairo', 'MacOSX', 'nbAgg', 'Qt4Agg', 'Qt4Cairo', 'Qt5Agg', 'Qt5Cairo',
'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']

Code for reproduction

We can reproduce it on both GitHub Actions and CircleCI using tox + pytest but only with the dev version of matplotlib.

Actual outcome

See traceback above.

Expected outcome

It does not throw ValueError.

Matplotlib version

Also, the Actions log.

xref astropy/astropy#11458

@QuLogic
Copy link
Member

QuLogic commented Apr 1, 2021

Probably related to #19603

@pllim
Copy link
Author

pllim commented Apr 2, 2021

@QuLogic , what does that mean for downstream setup? Do we have to completely change the way we set backend for CI? Can you please advise? Thanks!

@ianhi
Copy link
Contributor

ianhi commented Apr 2, 2021

I ran into this yesterday as well and opened: matplotlib/pytest-mpl#117

For me this was failing just from using pytest-mpl before getting to any tests:

INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/site-packages/pytest_mpl/plugin.py", line 124, in pytest_report_header
INTERNALERROR>     import matplotlib
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/site-packages/matplotlib/__init__.py", line 840, in <module>
INTERNALERROR>     rcParamsDefault = _rc_params_in_file(
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/site-packages/matplotlib/__init__.py", line 774, in _rc_params_in_file
INTERNALERROR>     config[key] = val  # try to convert to proper type or raise
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/site-packages/matplotlib/__init__.py", line 608, in __setitem__
INTERNALERROR>     raise ValueError(f"Key {key}: {ve}") from None
INTERNALERROR> ValueError: Key backend: '' is not a valid value for backend; supported values are ['GTK3Agg', 'GTK3Cairo', 'MacOSX', 'nbAgg', 'Qt4Agg', 'Qt4Cairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']

@pllim
Copy link
Author

pllim commented Apr 2, 2021

It is unclear to me where the fix should be. Does pytest-mpl need to be fixed to be compatible now, or is this unintentional side effect of matplotlib change?

@jklymak
Copy link
Member

jklymak commented Apr 2, 2021

I'm pretty sure it's unintentional and as @QuLogic suggested probably caused by the merged change in the template handling. @anntzer is the expert on the fallback logic and maybe can tease it apart.

@tacaswell tacaswell added this to the v3.5.0 milestone Apr 2, 2021
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Apr 2, 2021
@tacaswell
Copy link
Member

This is definitely a fix on our side, I will look at this this afternoon.

@pllim
Copy link
Author

pllim commented Apr 2, 2021

Thank you all for the quick responses!

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Apr 2, 2021
See comment in code.  Accounts for the fact that we can to directly specify the
"fallback" backend value.  This interprets the lack of a backend entry and an
empty backend entry the same.

closes matplotlib#19848
@tacaswell
Copy link
Member

See #19854

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants