The backend may not be GUI.
python
import matplotlib as mpl
mpl.use('tkagg')
Is evaluated before import matplotlib.pyplot` (written in the line above).
** ʻImport Error: No module named backend_tkagg.pyis displayed: ** It looks like the backend is not installed. Installation is required with apt-get or yum. For SUSE
sudo zypper in python-matplotlib-tk` (python3-matplotlib-tk for Python3)
** Now I can do it, but it's a hassle to do this every time ** Describe in the matplotlibrc file.
~/.config/matplotlib/matplotlibrc
backend : tkagg
For Linux, .config/matplotlib/matplotlibrc
On other platforms, .matplotlib/matplotlibrc
If you don't know
python
import matplotlib as mpl
print(mpl.get_configdir() + '/matplotlibrc')
http://python.dogrow.net/?p=186 http://matplotlib.org/users/customizing.html
Recommended Posts