环境
ubuntu 18.04 LTS
python 3.6.9
目的
import matplotlib.pyplot as plt
原因
缺少tkinter包
错误
ModuleNotFoundError: No module named ‘_tkinter’
解决方法
sudo apt-get install python3-tk
运行这行时,遇到了新的问题:
Temporary failure resolving ‘archive.ubuntu.com’
点击上面的链接http://archive.ubuntu.com/ubuntu,其实可以访问
需要配置:
vim /etc/resolv.conf
在文件中添加:
nameserver 202.96.134.133
nameserver 8.8.8.8
重启terminal,即可运行
仍存在的问题
由于是在docker中使用,虽然运行成功,但还存在一个错误:
Errors were encountered while processing:
resolvconf
E: Sub-process /usr/bin/dpkg returned an error code (1)
解决方法:
As mentioned in https://github.com/moby/moby/issues/1297 you can add the following line to your Dockerfile:
RUN echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections