Solve ImportError: No module named _tkinter when using matplotlib in python

1. If the python version is python3+

 sudo apt-get install python3-tk

 At this time, the corresponding tk version installed is the latest system, corresponding to the latest version of python

 At this time, the corresponding python version needs to be updated. For example, I was originally python3.5.2 and updated to python3.6.3.

 (The disadvantage is: the previously installed libraries have to be reinstalled, such as tensorflow, numpy, matplotlib, etc.)

2. If it is python2.7

 sudo apt-get install python-tk


If you have a good way, please leave a message.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326425088&siteId=291194637