matplotlib 3.0.0, cannot import name 'get_backend' from 'matplotlib'

cannot import name 'axes' from 'matplotlib'
import matplotlib cannot import name path
importerror cannot import name rcparams from matplotlib' (unknown location)
importerror cannot import name mpimg
importerror cannot import name _to_unmasked_float_array
cannot import name path from pathlib
importerror: cannot import name '_backend'
install matplotlib

Using Windows 10, anaconda as a package manager. I have a base environment running python 3.7 where matplotlib works fine. When I create a new environment and install both keras and matplotlib, I start to run into problems:

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\__init__.py", line 1111, in <module>
    rcParamsOrig = RcParams(rcParams.copy())
  File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\__init__.py", line 891, in __getitem__
    from matplotlib import pyplot as plt
  File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\pyplot.py", line 32, in <module>
    import matplotlib.colorbar
  File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\colorbar.py", line 40, in <module>
    import matplotlib._constrained_layout as constrained_layout
  File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\_constrained_layout.py", line 52, in <module>
    from matplotlib.legend import Legend
  File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\legend.py", line 43, in <module>
    from matplotlib.offsetbox import HPacker, VPacker, TextArea, DrawingArea
  File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\offsetbox.py", line 33, in <module>
    from matplotlib.image import BboxImage
  File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\image.py", line 19, in <module>
    from matplotlib.backend_bases import FigureCanvasBase
  File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\backend_bases.py", line 46, in <module>
    from matplotlib import (
ImportError: cannot import name 'get_backend'

Any suggestions? This is a fresh installation of conda. All I've done to get here is run conda create --name keras_env keras matplotlib, enter the environment, and try to import matplotlib. These are the packages conda installs:

## Package Plan ##

environment location: C:\...\Anaconda3\envs\keras_env

added / updated specs:
- keras
- matplotlib


The following NEW packages will be INSTALLED:

_tflow_select:       2.2.0-eigen
absl-py:             0.5.0-py36_0
astor:               0.7.1-py36_0
blas:                1.0-mkl
ca-certificates:     2018.03.07-0
certifi:             2018.10.15-py36_0
cycler:              0.10.0-py36h009560c_0
freetype:            2.9.1-ha9979f8_1
gast:                0.2.0-py36_0
grpcio:              1.12.1-py36h1a1b453_0
h5py:                2.8.0-py36h3bdd7fb_2
hdf5:                1.10.2-hac2f561_1
icc_rt:              2017.0.4-h97af966_0
icu:                 58.2-ha66f8fd_1
intel-openmp:        2019.0-118
jpeg:                9b-hb83a4c4_2
keras:               2.2.4-0
keras-applications:  1.0.6-py36_0
keras-base:          2.2.4-py36_0
keras-preprocessing: 1.0.5-py36_0
kiwisolver:          1.0.1-py36h6538335_0
libpng:              1.6.35-h2a8f88b_0
libprotobuf:         3.6.0-h1a1b453_0
markdown:            3.0.1-py36_0
matplotlib:          3.0.0-py36hd159220_0
mkl:                 2019.0-118
mkl_fft:             1.0.6-py36hdbbee80_0
mkl_random:          1.0.1-py36h77b88f5_1
numpy:               1.15.3-py36ha559c80_0
numpy-base:          1.15.3-py36h8128ebf_0
openssl:             1.0.2p-hfa6e2cd_0
pip:                 10.0.1-py36_0
protobuf:            3.6.0-py36he025d50_0
pyparsing:           2.2.2-py36_0
pyqt:                5.9.2-py36h6538335_2
python:              3.6.7-h33f27b4_0
python-dateutil:     2.7.3-py36_0
pytz:                2018.5-py36_0
pyyaml:              3.13-py36hfa6e2cd_0
qt:                  5.9.6-vc14h1e9a669_2
scipy:               1.1.0-py36h4f6bf74_1
setuptools:          40.4.3-py36_0
sip:                 4.19.8-py36h6538335_0
six:                 1.11.0-py36_1
sqlite:              3.25.2-hfa6e2cd_0
tensorboard:         1.11.0-py36he025d50_0
tensorflow:          1.11.0-eigen_py36h346fd36_0
tensorflow-base:     1.11.0-eigen_py36h45df0d8_0
termcolor:           1.1.0-py36_1
tornado:             5.1.1-py36hfa6e2cd_0
vc:                  14.1-h0510ff6_4
vs2015_runtime:      14.15.26706-h3a45250_0
werkzeug:            0.14.1-py36_0
wheel:               0.32.2-py36_0
wincertstore:        0.2-py36h7fe50ca_0
yaml:                0.1.7-hc54c509_2
zlib:                1.2.11-h8395fce_2

This issue has been reported here and has been fixed here. The fix will be available in matplotlib 3.0.1, which is scheduled to be release within the next few days.

Until then you may either use python <= 3.6.6 with matplotlib 3.0.0. Or you may use matplotlib 2.2.3 or you may try the fix proposed in the linked issue, namely to create a matplotlibrc file in one of the paths where matplotlib would find it.

ImportError: cannot import name 'get_backend' from 'matplotlib' in , matplotlib 3.0.0, cannot import name 'get_backend' from 'matplotlib' (3 import matplotlib.pyplot as plt Traceback (most recent call last): File  The fix will be available in matplotlib 3.0.1, which is scheduled to be release within the next few days. Until then you may either use python <= 3.6.6 with matplotlib 3.0.0. Or you may use matplotlib 2.2.3 or you may try the fix proposed in the linked issue , namely to create a matplotlibrc file in one of the paths where matplotlib would find it.

Try this:

pip uninstall matplotlib
python -m pip install --upgrade pip
pip install matplotlib

Worked perfectly for me

Can't import matplotlib · Issue #12601 · matplotlib/matplotlib · GitHub, Importing matplotlib fails with ImportError: cannot import name 'get_backend' from matplotlibrc causes import to fail 3.0.0 (didn't crash 2. matplotlib 3.0.0, cannot import name 'get_backend' from 'matplotlib' (2) This issue has been reported here and has been fixed here . The fix will be available in matplotlib 3.0.1, which is scheduled to be release within the next few days. Until then you may either use python <= 3.6.6 with matplotlib 3.0.0.

pip uninstall matplotlib
pip install --upgrade matplotlib

works perfectly!

Can not longer import Matplotlib · Issue #13270 · matplotlib , ImportError: cannot import name 'get_backend' from 'matplotlib' Operating system: Debian Stretch; Matplotlib version: 3.0.0; Matplotlib  Fix Python Matplotlib ImportError: cannot import name ‘_path’ Error: A Beginner Guide – Matplotlib Tutorial By admin | November 29, 2019 0 Comment

1643736 – matplotlib: cannot import name get_backend, Fixed In Version: python-matplotlib-3.0.1-1.fc30 number of selected component (if applicable): python3-matplotlib-3.0.0-2.fc30 Actual results: Failure due to matplotlib being unable to import its own get_backend function. conda uninstall matplotlib #let it do its thing conda install matplotlib #let it do its thing Then test it on the code you're trying to do and see if it works. In my case, it came down to a "_Path" issue in my original install that messed up things.

GitHub Stats for Matplotlib 3.0.2, PR #12717: Delete some if __name__ == "__main__" clauses. MacOS: Cannot import name 'format_exc'; #12169: Cannot install 3.0.0  Re: [Matplotlib-users] [ImportError]: cannot import name AxisConcatenator from "import matplotlib"

matplotlib, The axes module is the highest level of OO access to the library. when an executable that Matplotlib optionally depends on can't be found. A procedural interface is provided by the companion pyplot module, which may be imported directly, e.g.:: import matplotlib.pyplot as plt or using ipython:: ipython at your terminal, followed by:: In [1]: %matplotlib In [2]: import matplotlib.pyplot as plt at the ipython shell prompt.

Comments
  • have a base environment running python 3.7 where matplotlib works fine. It's best not to touch the base environment.
  • This is in python 3.6.7, so that alone doesn't solve it. But using matplotlib 2.2.3 works, so I will just keep it downgraded.
  • @user121664: It is the issue; the change that broke matplotlib 3.0.0 in Python 3.7 was also merged into Python 3.6.7. You can see the commit here. Python 3.6.6 would probably be fine, and once matplotlib 3.0.1 comes out, matplotlib 3.0.1 shouldn't have the compatibility issues.
  • The accepted answer says that this was an issue with matplotlib, which has since been fixed. How does this answer relate to the situation?
  • The accepted answer says that this was an issue with matplotlib, which has since been fixed. How does this answer relate to the situation?