我在 Ubuntu 16.04 中遇到了 tkinter 模块问题,运行 python3.6 程序需要加载该模块,但是找不到它:
File "/usr/local/bin/declooptor", line 11, in <module>
load_entry_point('declooptor==0.1.0', 'console_scripts', 'declooptor')() File
"/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py",
line 487, in load_entry_point
return get_distribution(dist).load_entry_point(group, name) File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py",
line 2728, in load_entry_point
return ep.load() File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py",
line 2346, in load
return self.resolve() File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py",
line 2352, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0) File
"/usr/local/lib/python3.6/dist-packages/declooptor-0.1.0-py3.6.egg/declooptor/detector.py",
line 39, in <module> File
"/usr/local/lib/python3.6/dist-packages/matplotlib/pyplot.py", line
2374, in <module>
switch_backend(rcParams["backend"]) File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_tkagg.py",
line 1, in <module>
from . import _backend_tk File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/_backend_tk.py", line 5, in <module>
import tkinter as Tk ModuleNotFoundError: No module named 'tkinter'
但是当我输入时sudo apt install python3-tk
我得到:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-tk is already the newest version (3.5.1-1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
which python3.6
返回/usr/bin/python3.6
我已经检查了文件夹/usr/lib/python3/dist-packages/
,/usr/lib/python3.5
但/usr/lib/python3.6
没有tkinter
文件夹,尽管它们现在可能有另一个名字?
有人知道该怎么办吗?