我是靠谱客的博主 幸福黑猫,这篇文章主要介绍错误RuntimeWarning: Glyph xxxxx missing from current font的产生原因分析,无法解析当前字体错误RuntimeWarning: Glyph xxxxx missing from current font的产生原因分析,无法解析当前字体,现在分享给大家,希望可以做个参考。
错误RuntimeWarning: Glyph xxxxx missing from current font的产生原因分析,无法解析当前字体
系统版本:macOS11,
python版本:python3.9.1
报错原因:matplotlib中文乱码问题
解决办法:
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()
然后退出python环境,在终端使用 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、完成字体配置,可正常使用
最后
以上就是幸福黑猫最近收集整理的关于错误RuntimeWarning: Glyph xxxxx missing from current font的产生原因分析,无法解析当前字体错误RuntimeWarning: Glyph xxxxx missing from current font的产生原因分析,无法解析当前字体的全部内容,更多相关错误RuntimeWarning:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复