报错:
findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei
解决方法:
1、下载SimHei.tff文件。
2、打开终端,打开pytorch环境
python
import matplotlib
print(matplotlib.matplotlib_fname()) # matplotlib字体配置文件路径
根据这个地址,找到字体存放位置,将字体放入相应文件夹内
3、删除缓存:先找到缓存地址
import matplotlib as mpl
mpl.get_cachedir()
找到缓存地址下的json文件,将其删除(.chche文件是隐藏文件,需要按ctrl+H,将其显示出来)
最后打开这个json文件,即可看到已经导入的simhei字体