【matplotlib】 findfont: Font family [‘Times New Roman‘] not found. Falling back to DejaVu Sans.

1、简介

绘制图时显示缺少字体

2、解决

1、目录 C:\Windows\Fonts 下搜索找到 Time New Roman 字体,包含 ttf 格式的四个文件。
2、将其复制到服务器上 matplotlib 库对应的 fonts/ttf 文件夹下。
上述 ttf 字体文件复制的目标地址为:

/home/anaconda3/envs/pytorch/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf

3、删除之前的缓冲,地址为home/用户/.cache/matplotlib目录,重新运行程序即可。地址中的wbx是用户名,根据实际情况自行更改。找不到cache文件夹是因为其为隐藏文件夹,可ctrl+h将其显示。

3、参考

使用matplotlib时缺失字体,findfont: Font family [‘Times New Roman‘] not found. Falling back to DejaVu Sans.

猜你喜欢

转载自blog.csdn.net/lj2048/article/details/120359052
今日推荐