ImportError: No module named '_tkinter', please install the python3-tk package
在这方面,我已经讨论了所有类似的问题,并尝试了那里提出的解决方案。但我无法解决这个错误,尽管我的
虽然在我的项目中,我不使用tkinter,但是当我尝试运行文件时,我得到了与
Traceback (most recent call last):
File"/usr/lib/python3.5/tkinter/init.py", line 36, in
import _tkinter
ImportError: No module named '_tkinter'During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File"/home/manuelanayantarajeyaraj/PycharmProjects/ChatbotWord2Vec/main.py", line 2, in
from matplotlib import pyplot as plt
File"/home/manuelanayantarajeyaraj/usr/myProject/my_project/lib/python3.5/site-packages/matplotlib/pyplot.py", line 115, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File"/home/manuelanayantarajeyaraj/usr/myProject/my_project/lib/python3.5/site-packages/matplotlib/backends/init.py", line 62, in pylab_setup
[backend_name], 0)
File"/home/manuelanayantarajeyaraj/usr/myProject/my_project/lib/python3.5/site-packages/matplotlib/backends/backend_tkagg.py", line 4, in
from . import tkagg # Paint image to Tk photo blitter extension.
File"/home/manuelanayantarajeyaraj/usr/myProject/my_project/lib/python3.5/site-packages/matplotlib/backends/tkagg.py", line 5, in
from six.moves import tkinter as Tk
File"/home/manuelanayantarajeyaraj/usr/myProject/my_project/lib/python3.5/site-packages/six.py", line 92, in get
result = self._resolve()
File"/home/manuelanayantarajeyaraj/usr/myProject/my_project/lib/python3.5/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File"/home/manuelanayantarajeyaraj/usr/myProject/my_project/lib/python3.5/site-packages/six.py", line 82, in _import_module
import(name)
File"/usr/lib/python3.5/tkinter/init.py", line 38, in
raise ImportError(str(msg) + ', please install the python3-tk package')
ImportError: No module named '_tkinter', please install the python3-tk package
因此,我导航到解释器的位置,创建了一个virtualenv,并使用以下方法安装了
1 | sudo apt-get install python3-tk |
当我检查时,所有的包裹似乎都是最新的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Reading package lists... Done Building dependency tree Reading state information... Done python3-tk is already the newest version (3.6.5-3~16.04.york0.2). The following packages were automatically installed and are no longer required: libappindicator1 libindicator7 libllvm4.0 linux-headers-4.10.0-28 linux-headers-4.10.0-28-generic linux-headers-4.13.0-36 linux-headers-4.13.0-36-generic linux-headers-4.13.0-37 linux-headers-4.13.0-37-generic linux-image-4.10.0-28-generic linux-image-4.13.0-36-generic linux-image-4.13.0-37-generic linux-image-extra-4.10.0-28-generic linux-image-extra-4.13.0-36-generic linux-image-extra-4.13.0-37-generic linux-signed-image-4.10.0-28-generic linux-signed-image-4.13.0-36-generic linux-signed-image-4.13.0-37-generic Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 37 not upgraded. |
但我仍然得到同样的导入错误
在这方面的任何建议都将受到高度赞赏。
当您导入
1 2 3 | import matplotlib matplotlib.use("agg") import matplotlib.pyplot as plt |
消息表明,当运行
1 | sudo apt-get install python3.5-tk |