You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Importing matplotlib fails with ImportError: cannot import name 'get_backend' from 'matplotlib'.
Code for reproduction
importmatplotlib
Actual outcome
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.7/site-packages/matplotlib/__init__.py", line 1080, in <module>
rcParamsOrig = RcParams(rcParams.copy())
File "/usr/lib/python3.7/site-packages/matplotlib/__init__.py", line 870, in __getitem__
from matplotlib import pyplot as plt
File "/usr/lib/python3.7/site-packages/matplotlib/pyplot.py", line 33, in <module>
import matplotlib.image
File "/usr/lib/python3.7/site-packages/matplotlib/image.py", line 18, in <module>
from matplotlib.backend_bases import FigureCanvasBase
File "/usr/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 46, in <module>
from matplotlib import (
ImportError: cannot import name 'get_backend' from 'matplotlib' (/usr/lib/python3.7/site-packages/matplotlib/__init__.py)
Expected outcome
Matplotlib is imported
Matplotlib version
Operating system: GNU/Linux
Matplotlib version: 3.0 git master
Python version: 3.7.1
Python from Arch repo, matplotlib from git master.
I can confirm by building from master branch in a clean chroot, during the tests part:
E _pytest.config.ConftestImportFailure: (local('/build/python-matplotlib-git/src/matplotlib-test/lib/matplotlib/tests/conftest.py'), (<class 'ImportError'>, ImportError("cannot import name 'get_backend' from 'matplotlib' (/build/python-matplotlib-git/src/matplotlib-test/lib/matplotlib/__init__.py)"), <traceback object at 0x7f591217ff08>))
Activity
anntzer commentedon Oct 23, 2018
I can repro with 3.7.1 (one needs to not have a matplotlibrc to repro, this can be done e.g. by pointing MPLCONFIGDIR to an empty directory).
I think(??) this is likely due to python/cpython@d45a961 (specifically python/cpython@d45a961#diff-2131209d0deb0e50c93a88ec6c7b0d52R2487) which makes RcParams.copy now use our own
__getitem__instead of skipping it.ArchangeGabriel commentedon Oct 23, 2018
I can confirm by building from master branch in a clean chroot, during the tests part:
QuLogic commentedon Oct 23, 2018
CI is also failing on this same issue.
tacaswell commentedon Oct 23, 2018
Oh, that is exciting....
tacaswell commentedon Oct 23, 2018
I clearly have not been doing enough development work recently as I missed this in my all-the-master-branch enviroment 😞
FIX: over-ride 'copy' on RcParams