Skip to content

AttributeError: module 'matplotlib' has no attribute 'backends' #18022

@umesh-timalsina

Description

@umesh-timalsina

Bug report

Bug summary
Switching backends using matplotlib v3.3.0 fails for custom backend. I have a custom backend developed for matplotlib. Which is used to get state of the current figure data. Before v3.3.0, I used MPLBACKEND env variable to switch backends. This fails in v3.3.0 it fails with the following error message:

File "/path/to/conda/python3.7/site-packages/matplotlib/pyplot.py", line 283, in switch_backend
    matplotlib.backends.backend = newbackend
AttributeError: module 'matplotlib' has no attribute 'backends'

Code for reproduction

$ export MPLBACKEND=module://my_custom_backend
Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'3.3.0'
>>> from matplotlib import pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/umesh/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2319, in <module>
    switch_backend(rcParams["backend"])
  File "/home/umesh/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py", line 283, in switch_backend
    matplotlib.backends.backend = newbackend
AttributeError: module 'matplotlib' has no attribute 'backends'
>>> 

Actual outcome

AttributeError: module 'matplotlib' has no attribute 'backends'

Matplotlib version

  • Operating system: (Linux Mint 19.3 Tricia)
  • Matplotlib version: 3.3.0
  • Matplotlib backend : Problem with switching backend
  • Python version: 3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions