本文主要是介绍【python】ImportError: No module named '_tkinter', please install the python3-tk package,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在python3.6下运行程序报错:
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 "main.py", line 1, in <module>from test.env import *File "/home/test/env.py", line 2, in <module>import matplotlib.pyplot as pltFile "/usr/local/lib/python3.6/dist-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/dist-packages/matplotlib/backends/__init__.py", line 62, in pylab_setup[backend_name], 0)File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_tkagg.py", line 4, in <module>from . import tkagg # Paint image to Tk photo blitter extension.File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/tkagg.py", line 5, in <module>from six.moves import tkinter as TkFile "/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 _resolvereturn _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
根据这个报错信息尝试安装python3-tk,无对应包。
仔细查看错误信息是与matplotlib包有关,可能是配置问题,重新安装此包:
pip uninstall matplotlib
pip install matplotlib
重新运行程序,成功!
这篇关于【python】ImportError: No module named '_tkinter', please install the python3-tk package的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!