Closed
Description
Bug report
I just wanted to use matplotlib to draw a line graph and save it to a file, but every time I try to import the pyplot module I get the abovementioned error message.
python3 -c "import matplotlib.pyplot"
Actual outcome
>>> import matplotlib.pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/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.6/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from six.moves import tkinter as Tk
File "/usr/local/lib/python3.6/site-packages/six.py", line 92, in __get__
result = self._resolve()
File "/usr/local/lib/python3.6/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/usr/local/lib/python3.6/site-packages/six.py", line 82, in _import_module
__import__(name)
File "/usr/local/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
Expected outcome
Whatever happens when import matplotlib.pyplot
succeeds
Matplotlib version
- Operating System: Windows Subsystem for Linux
- Matplotlib Version: 2.0.2
- Python Version: 3.6.0
I installed matplotlib using pip.
Doing sudo apt-get install python3-tk
, as recommended by someone on Stack Overflow, didn't help.