Font family ['sans-serif'] not found.Falling back to DejaVu Sans.解决办法

1、在终端python 的环境下,查看字体路径

import matplotlib    
print(matplotlib.matplotlib_fname())

在这里插入图片描述
2、下载SimHei
官方下载网址,并前往指定目录:/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf,将下载好的SimHei移动到该目录下。
3、删除matplotlib的缓冲目录
在终端python 的环境下,输入如下指令,查看matplotlib的字体缓存路径:

import matplotlib
matplotlib.get_cachedir()

然后使用rm -rf +路径删除缓存
在这里插入图片描述
4、修改matplotlibrc文件
修改/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/mpl-data/matplotlibrc,修改内容如下:

 font.family         : sans-serif   
 # 去掉前面的#     
 font.sans-serif     : SimHei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif  
 # 去掉前面的#,并在冒号后面添加SimHei
 axes.unicode_minus  : False
 # 去掉前面的#,并将True改为False

5、重新启动Eclipse。

发布了29 篇原创文章 · 获赞 10 · 访问量 3189

猜你喜欢

转载自blog.csdn.net/sinat_40875078/article/details/104326855