Ubuntu16.10安装python3-tk

Ubuntu16.10安装python3-tk

  • 问题说明
    在python3下安装好matplotlib后,准备训练模型时,终端报错提示需要安装python3-tk,ImportError: No module named ‘_tkinter’

按照提示终端输入:

sudo apt-get install python3-tk 

不行,说是找不到对应的资源

  • 换源

这下好办了,网上搜索下Ubuntu16.10的更新源,尝试了下发现没什么用,果断搜索Ubuntu16.04的更新源,这里贴一下阿里的源:

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
  • 修改源的方法
sudo vi /etc/apt/sources.list
把上面的源直接覆盖该文件,注意先备份下sources.list

sudo apt-get update(这里需要等待一会)

这里需要注意/etc/apt/sources.list.d/ubuntukylin.list是否与xenial一致,如果不一致改成一致:
deb http://archive.ubuntukylin.com:10006/ubuntukylin xenial main

如果过程中出现了类似于下面的错误时:
由于没有公钥,无法验证下列签名: NO_PUBKEY CBCBxxxxxxxxxxxx
仓库 xxx 没有数字签名。
N: 无法认证来自该源的数据,所以使用它会带来潜在风险。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。

采取下面方法修复:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CBCBxxxxxxxxxxxx
  • 安装python3-tk
sudo apt-get install python3-tk

这里要注意若是安装出错,检查一下是否有:
python3-tk 已经是最新版 (3.5.2-1)
这种提示,有提示说明update时python3-tk已经安装好了

至此,python3-tk安装问题就完美解决了

你可能感兴趣的:(机器学习)