解决matplotlib问题: 没有‘Times New Roman‘字体

UserWarning: findfont: Font family [u’Times New Roman’] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext]))
报错原因为系统中没有Times New Roman 这个字体。

解决方案:

(1)下载安装Times New Roman字体。

sudo apt install font-manager
(2)删除matplotlib的缓存:

rm ~/.cache/matplotlib -rf
注意:可能缓存地址不对,使用代码 fontmanager.get_cachedir() 或 fontmanager._fmcache获取缓存地址。
有相同爱好的可以进来一起讨论哦:企鹅群号:1046795523

学习视频资料:http://www.makeru.com.cn/live/1392_1164.html?s=143793

猜你喜欢

转载自blog.csdn.net/wy122222222/article/details/109031853
今日推荐