python:linux上matplotlib找不到手动添加的字体

一,linux上安装了黑体,fc-list可以看到

$ fc-list | grep hei
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: 文泉驿正黑,WenQuanYi Zen Hei,文泉驛正黑:style=Regular
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: 文泉驿点阵正黑,WenQuanYi Zen Hei Sharp,文泉驛點陣正黑:style=Regular
/usr/share/fonts/truetype/simhei/simhei.ttf: 黑体,SimHei:style=Regular
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: 文泉驿等宽正黑,WenQuanYi Zen Hei Mono,文泉驛等寬正黑:style=Regular

二,如果matplotlib执行时仍然找不到黑体:

在 Linux 中,fc-list 能看到字体但 Matplotlib 找不到,
通常是因为 Matplotlib 的字体缓存未更新字体安装路径不在其检索范围内
直接解决办法是清理 Matplotlib 缓存确认其内部加载列表
 
$ rm -rf ~/.cache/matplotlib
 
posted @ 2026-05-15 10:53  刘宏缔的架构森林  阅读(13)  评论(0)    收藏  举报