Skip to content

Invalid backend when importing Matplotlib #19857

Closed

Description

@rayosborn

Bug report

Bug summary

After installing the latest development version on the master branch using pip install . from the cloned Git repository, imports of Matplotlib fail because of an empty backend string ('') when reading rcParamDefaults from a file. If I switch to the 'v3.4.x' branch, there is no problem.

Code for reproduction

>>> import matplotlib

Actual outcome
Using matplotlib-3.4.1.post292+g4085fc7ad

Python 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:12:38) 
[Clang 11.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/rosborn/opt/miniconda3/envs/py38/lib/python3.8/site-packages/matplotlib/__init__.py", line 839, in <module>
    rcParamsDefault = _rc_params_in_file(
  File "/Users/rosborn/opt/miniconda3/envs/py38/lib/python3.8/site-packages/matplotlib/__init__.py", line 773, in _rc_params_in_file
    config[key] = val  # try to convert to proper type or raise
  File "/Users/rosborn/opt/miniconda3/envs/py38/lib/python3.8/site-packages/matplotlib/__init__.py", line 607, in __setitem__
    raise ValueError(f"Key {key}: {ve}") from None
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']

Expected outcome
Using matplotlib-3.4.1+5.g272860be0

Python 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:12:38) 
[Clang 11.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.rcParamsDefault['backend']
'MacOSX'

Matplotlib version

  • Operating system: MacOS v10.15.7
  • Matplotlib version: 3.4.1.post292+g4085fc7ad
  • Matplotlib backend: ? (I can't query it because of the import failure. With v3.4.1, it's 'MacOSX')
  • Python version: 3.8.8

Both versions were installed with pip install . from within the Matplotlib cloned repository, having checked out the master and v3.4.x branches, respectively, for installation within a conda environment.

Activity

  1. rayosborn commented on Apr 3, 2021

    @rayosborn
    Author

    Less than a minute after posting this, I see that #19855 fixes the issue. That's amazingly quick service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions