jupyter matplotlib 乱码

1. 查看 matplotlib 字体文件夹

import matplotlib 
print(matplotlib.matplotlib_fname()) 
/usr/lib64/python3.6/site-packages/matplotlib/mpl-data/matplotlibrc

2. 下载字体

cd /usr/lib64/python3.6/site-packages/matplotlib/mpl-data/
cd fonts 
 从这个 https://www.fontpalace.com/font-download/SimHei/ 网址下载字体

3. 修改配置文件

vim /usr/lib64/python3.6/site-packages/matplotlib/mpl-data/matplotlibrc
去掉# 注释,修改成以下,font.sans-serif 加上SimHei

font.family         : sans-serif       
font.sans-serif     : SimHei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif

4. 删除缓存

rm -rf ~/.cache/matplotlib 

5. 重启jupyter,大功告成

你可能感兴趣的:(jupyter matplotlib 乱码)