欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

服务器 Font family [‘sans-serif‘] not found.Falling back to DejaVu Sans.解决办法

发布时间:2025/3/15 49 豆豆
生活随笔 收集整理的这篇文章主要介绍了 服务器 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 # 去掉前面的#,并在冒号后面添加SimHeiaxes.unicode_minus : False# 去掉前面的#,并将True改为False

总结

以上是生活随笔为你收集整理的服务器 Font family [‘sans-serif‘] not found.Falling back to DejaVu Sans.解决办法的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。