Ubuntu16.04
python3.5
matplotlib
我利用matplotlib编写了一个十分简单的画图脚本,但是遇到了这个报错
UserWarning: findfont: Font family [u'sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
font.family : sans-serif
font.sans-serif : SimHei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
axes.unicode_minus,将True改为False,作用就是解决负号'-'显示为方块的问题
rm -rf ~/.cache/matplotlib
这就解决问题了,可是 重启之后我又碰到了另外一个报错
/usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
解决方法:
sudo apt-get install libfreetype6-dev libxft-dev
https://blog.csdn.net/dgatiger/article/details/50414549
https://github.com/matplotlib/matplotlib/issues/8876
http://wenda.chinahadoop.cn/question/6828