停了两个月课的小韩同学终于又开始学习数据分析了...刚一上课就遇到了很多环境问题...
问题一:
环境中已经安装了matplotlib库仍然报了No module named matplotlib.pyplot的错误。
csdn解决方法一:重装matplotlib库
# 卸载pip uninstall matplotlib# 安装pip install matplotlib
但是操作之后仍是报同样错误。
csdn解决方法二:在导入matplotlib库后,且在matplotlib.pyplot库被导入前加“matplotlib.use(‘agg’)”语句。
import numpy as npimport matplotlibmatplotlib.use('agg')import matplotlib.pyplot as plt # matplotlib.use('agg')必须在本句执行前运行
成功解决~
问题二:
python中使用matplotlib库画图失败
运行程序后报错如下:
UserWarning:Matplotlib is currently using agg, which is a non-GUI backend, so cannot showthe figure.
解决方法:在开头加上下列代码