错误信息如图:

ubuntu系统中使用matplotlib出现字体错误findfont: Font family ['sans-serif'] not found

下载simhei字体:

http://www.xiazaiziti.com/210356.html

ubuntu系统中使用matplotlib出现字体错误findfont: Font family ['sans-serif'] not found

把下载的字体复制到目录:

ubuntu系统中使用matplotlib出现字体错误findfont: Font family ['sans-serif'] not found

 

 

在home目录下,执行 ctrl + h ,打开隐藏目录, 删除 ~/.cache/matplotlib的缓冲目录

ubuntu系统中使用matplotlib出现字体错误findfont: Font family ['sans-serif'] not found
修改 ./venv/lib/python3.5/site-packages/matplotlib/mpl-data 里面的matplotlibrc文件,修改三处如下:

195 行:

ubuntu系统中使用matplotlib出现字体错误findfont: Font family ['sans-serif'] not found

207行 添加SimHei即可:

ubuntu系统中使用matplotlib出现字体错误findfont: Font family ['sans-serif'] not found

322行,把True改为False:

ubuntu系统中使用matplotlib出现字体错误findfont: Font family ['sans-serif'] not found

重新启动pytho即可

相关文章: