0. 前言
在ipython环境中,要用到matlotlib库,运行.py文件时,提示以下错误:
No module named _tkinter, please install the python-tk package。
配置环境为ubuntu16.04。本文目的为解决上述问题。
1.Tkinter问题描述
按照普通的思路,上述错误出现的原因可能时时python环境缺少tk的包,于是进行输入命令:sudo apt-get install python-tk
但也提示错误:tcl8.6.8,tk8.6.8 not found。
Google一下,tcl为“工具控制语言(Tool Command Language)”的缩写,其面向对象为otcl语言。Tk 是 Tcl“图形工具箱”的扩展,它提供各种标准的 GUI 接口项,以利于迅速进行高级应用程序开发。
2.安装tcl和tk
(1) 安装tcl,依次执行下面命令:
tar -zvxf tar -xzvf tcl8.6.8-src.tar.gz
cd tcl8.6.1/unix
./configure
make
sudo install make
(2)如法炮制,安装tk8.6.8:
tar -xzvf tk8.6.8-src.tar.gz
cd tk8.6.8/unix
./configure
make
sudo install make
但执行到make命令时提示错误:没有X11/Xlib.的文件或目录,见下图。