没有名为 tkinter 的模块

没有名为 tkinter 的模块

我以前从未遇到过这个问题。我该如何修复它?它说没有名为 tkinter 的模块

(env_maskrcnn) haziq@vita-workstation2:~/human-pose-estimation$ ./run.sh
Traceback (most recent call last):
  File "pose_estimation/valid.py", line 32, in <module>
    import dataset
  File "/home/haziq/human-pose-estimation/pose_estimation/../lib/dataset/__init__.py", line 12, in <module>
    from .coco import COCODataset as coco
  File "/home/haziq/human-pose-estimation/pose_estimation/../lib/dataset/coco.py", line 19, in <module>
    from pycocotools.coco import COCO
  File "/home/haziq/.local/lib/python3.6/site-packages/pycocotools/coco.py", line 49, in <module>
    import matplotlib.pyplot as plt
  File "/home/haziq/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2374, in <module>
    switch_backend(rcParams["backend"])
  File "/home/haziq/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 207, in switch_backend
    backend_mod = importlib.import_module(backend_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/haziq/.local/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 1, in <module>
    from . import _backend_tk
  File "/home/haziq/.local/lib/python3.6/site-packages/matplotlib/backends/_backend_tk.py", line 5, in <module>
    import tkinter as Tk
ModuleNotFoundError: No module named 'tkinter'

答案1

尝试运行:

sudo apt install python3-tk

它将tkinter为 安装模块python 3

答案2

有很多选择 - 使用apt-cache search tkinter后您就会看到:

$ apt-cache search tkinter
idle - IDE for Python using Tkinter (default version)
idle-python2.7 - IDE for Python (v2.7) using Tkinter
idle3 - IDE for Python using Tkinter (default version)
python-tk - Tkinter - Writing Tk applications with Python
python-tk-dbg - Tkinter - Writing Tk applications with Python (debug extension)
python3-tk - Tkinter - Writing Tk applications with Python 3.x
python3-tk-dbg - Tkinter - Writing Tk applications with Python 3.x (debug extension)
idle-python3.5 - IDE for Python (v3.5) using Tkinter
libsnack-alsa - Sound extension to Tcl/Tk and Python/Tkinter - ALSA files
libsnack-oss - Sound extension to Tcl/Tk and Python/Tkinter - OSS files
pypy-tk - Tkinter module for PyPy (an alternative Python interpreter)
python-easygui - module for very simple, very easy GUI programming in Python
python-editobj - Python object editor
python-opengl - Python bindings to OpenGL (Python 2)
python-pmw - Pmw -- Python MegaWidgets
python-pmw-doc - Pmw -- Python MegaWidgets
python-tksnack - Sound extension to Tcl/Tk and Python/Tkinter - Python 2.x library
python3-easygui - module for very simple, very easy GUI programming in Python3
python3-opengl - Python bindings to OpenGL (Python 3)
python3-tksnack - Sound extension to Tcl/Tk and Python/Tkinter - Python 3.x library
tcl-snack - Sound extension to Tcl/Tk and Python/Tkinter - Tcl/Tk library
tcl-snack-dev - Sound extension to Tcl/Tk and Python/Tkinter - development files
tcl-snack-doc - Sound extension to Tcl/Tk and Python/Tkinter - documentation

相关内容