我正在尝试使用python3.6导入matplotlib.pyplot,但会出现错误。
ModuleNotFoundError:没有名为' _tkinter
的模块
直接在python脚本中导入tkinter会产生同样的错误。
我也尝试过安装tkinter,但仍然无法在python3.6中导入
$ sudo apt-get 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).
The following packages were automatically installed and are no longer required:
libexpat1:i386 libmpdec2:i386 libpython3-dev libpython3-stdlib:i386 libpython3.5-dev libpython3.5-minimal:i386
libpython3.5-stdlib:i386 libreadline6:i386 libsnapd-glib1 libsqlite3-0:i386 libssl1.0.0:i386 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-headers-4.13.0-38
linux-headers-4.13.0-38-generic linux-image-4.13.0-36-generic linux-image-4.13.0-37-generic linux-image-4.13.0-38-generic
linux-image-extra-4.13.0-36-generic linux-image-extra-4.13.0-37-generic linux-image-extra-4.13.0-38-generic
linux-signed-image-4.13.0-37-generic linux-signed-image-4.13.0-38-generic snapd-login-service
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ python
Python 3.6.3 (default, Apr 13 2018, 13:00:29)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
安装python3.6-tk给出
$ sudo apt-get install python3.6-tk
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3.6-tk
E: Couldn't find any package by glob 'python3.6-tk'
E: Couldn't find any package by regex 'python3.6-tk'
使用python2.7和3.5时,Matplotlib和tkinter工作正常。我想问题是为python3.6安装tkinker,但我没能安装它。
谢谢