from matplotlib.backends import _tkagg ImportError: cannot import name _tkagg from matplotlib.backends import _tkagg ImportError: cannot import name _tkagg python python

from matplotlib.backends import _tkagg ImportError: cannot import name _tkagg


I just ran into this (Ubuntu 15.10 but same idea) and fixed it by:

sudo apt-get install tk-devpip uninstall -y matplotlibpip --no-cache-dir install -U matplotlib

I think the third step was the critical one; if the cache is permitted then pip appeared to be just using the previously-built installation of matplotlib.

You can also manually remove the previously-built matplotlib; on Ubuntu it lives in ~/.cache/pip somewhere. (I couldn't find a way for pip to clean up its cache unfortunately.)


Python 3.7.4 on Windows 10, replacing NavigationToolbar2TkAgg with NavigationToolbar2Tk works for me.

Change from:

from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2TkAgg)

To:

from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk)


Try following this scenario:

sudo apt-get updatesudo apt-get install tk tk-devsudo pip uninstall matplotlib sudo pip install matplotlib

EDIT:

Try:

sudo pip uninstall matplotlib sudo apt-get install python-matplotlib

EDIT2:

sudo apt-get install tk8.6-devsudo apt-get remove python-matplotlibsudo apt-get install python-matplotlib