The current version of Python3 is 3.5.2 when I import matplotlib it retuned the following error
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.5/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python3.5/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from six.moves import tkinter as Tk
File "/usr/local/lib/python3.5/site-packages/six.py", line 92, in __get__
result = self._resolve()
File "/usr/local/lib/python3.5/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/usr/local/lib/python3.5/site-packages/six.py", line 82, in _import_module
__import__(name)
File "/usr/local/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
And import tkinter
Python 3.5.2 (default, Jan 19 2017, 11:29:22)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
>>>
It seems that tkinter has already been intalled.
I have installed tk and tcl by
sudo apt-get install tk-dev
sudo apt-get install tk8.6-dev
And OS is Ubuntu 14.04.
I think it is the reason that TK was not configured on Python3, but I'm not sure. Many people said I should rebuild and reinstall Python3 with tk, however I don't think it is an elegant way to solve this problem.
How can I fix this problem?