findfont: Font family 'Times New Roman' not found.

这是因为在python环境中的matplotlib文件夹下没有这个字体的文件。
对于windows系统,请参考:https://blog.csdn.net/qq_49323609/article/details/139026798
Macos系统:

  1. 先打开软件:
  2. 找到字体的路径
  3. 然后模仿以上https://blog.csdn.net/qq_49323609/article/details/139026798链接中的路径,找到类似于"/home/user/anaconda3/envs/pytorch/lib/python3.9/site-packages/matplotlib/mpl-data/fonts/ttf"的文件夹,直接将文件复制过去。
  4. 最后需要将matplotlib的字体缓存删除:rm -r ~/.cache/matplotlib/

Ubuntu系统:
同样地操作,可以将本地系统中的.ttf文件上传到对应的/matplotlib/mpl-data/fonts/ttf文件夹下。如果是macos系统,可以使用scp 本地文件路径 服务器用户名@ip:服务器对应地址。需要注意的是,对于Times New Roman本地路径,这个Times New Roman.ttf文件带有空格,会找不到,可以使用转义字符Times\ New\ Roman

posted @ 2024-06-29 17:31  2426051714  阅读(796)  评论(0)    收藏  举报