ImportError: No module named '_tkinter', please install the python3-tk package ImportError: No module named '_tkinter', please install the python3-tk package tkinter tkinter

ImportError: No module named '_tkinter', please install the python3-tk package


When you import matplotlib, it will probably be trying to use the tk backend as the default. If you didn't install tk, or you do not want to use it anywhere else in your project, then a possible solution would be to simply use a different backend:

import matplotlibmatplotlib.use("agg")import matplotlib.pyplot as plt


The message indicates that when you run sudo apt-get install python3-tk it tells you that tkinter is sintalled for Python3.6.5, but on the other hand, the ImportError is related to Python3.5. So I believe this should resolve your problem:

sudo apt-get install python3.5-tk