matplotlib.pyplot error when importing: ImportError: No module named '_tkinter', please install the python3-tk package
See original GitHub issueIt looks like there is some package missing (python3-tk?), which prevents from normal usage of matplotlib.pyplot
. Is there any workaround for this issue? Thanks!
Python 3.6.3 (default, Oct 6 2017, 08:44:35)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot
Traceback (most recent call last):
File "/usr/lib/python3.6/tkinter/__init__.py", line 37, in <module>
import _tkinter
ModuleNotFoundError: No module named '_tkinter'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/matplotlib/pyplot.py", line 116, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/__init__.py", line 60, in pylab_setup
[backend_name], 0)
File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from six.moves import tkinter as Tk
File "/usr/local/lib/python3.6/dist-packages/six.py", line 92, in __get__
result = self._resolve()
File "/usr/local/lib/python3.6/dist-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/usr/local/lib/python3.6/dist-packages/six.py", line 82, in _import_module
__import__(name)
File "/usr/lib/python3.6/tkinter/__init__.py", line 39, in <module>
raise ImportError(str(msg) + ', please install the python3-tk package')
ImportError: No module named '_tkinter', please install the python3-tk package
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
python - matplotlib error - no module named tkinter
Go to start menu, type Apps & features,; Search for "python" in the search box,; Select the Python version (e.g. Python 3.8.3rc1(32-bit)) and...
Read more >Getting "No module named '_tkinter'" error · Issue #9017
I installed matplotlib using pip.. I installed Python 3.6 from source though, omitting the tk packages as I didn't need them. Guess I' ......
Read more >ModuleNotFoundError: No module named 'tkinter' in Python
The Python "ModuleNotFoundError: No module named 'tkinter'" occurs when tkinter is not installed in our Python environment.
Read more >Python error ImportError No module named tkinter please ...
I am trying to install python on Linux and I am getting the following error: ImportError: No module ... package. How do I...
Read more >No module named _tkinter, please install the python-tk package
You are getting this error because you have not installed tkinter locally. You can run the install command to download and install tkinter....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When you want to use matplotlib in deepo, we suggest using a non-interactive backend such as
agg
. In your figure-generating script, just call thematplotlib.use()
directive before importing pylab or pyplot:Hi, In the below case
This call to matplotlib.use() has no effect because the backend has already
Just restart the terminal.