解决matplotlib中文显示乱码问题

问题

findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei

解决方法

import matplotlib 
print(matplotlib.matplotlib_fname())

输出:xxx/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc

下载 http://129.204.205.246/downloads/SimHei.ttf
复制到 xxx/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/ttf

python字体缓存文件

import matplotlib
print(matplotlib.get_cachedir())

rm -rf 输出的地址/*

posted @ 2023-10-16 14:15  源世  阅读(282)  评论(0编辑  收藏  举报