python 3.x – ImportError: No module named _tkinter, please install the python3-tk package
python 3.x – 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 didnt 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 matplotlib
matplotlib.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