Linux jupyter notebook Matplotlib 无法显示汉字

Linux jupyter notebook Matplotlib 无法显示汉字

问题:

使用matplotlib画图时, 无法显示汉字, 显示出来一堆方框

解决办法:

python 复制代码
# 1. 安装字体
sudo apt-get install fonts-wqy-zenhei  # 安装文泉驿字体

# 2. 检查字体是否安装成功
fc-list | grep "WenQuanYi Zen Hei"
fc-cache -fv

# 3. 在 jupyter notebook 中清除 matplotlib 缓存
import matplotlib
import shutil
shutil.rmtree(matplotlib.get_cachedir())

# 4. 再试试, 应该就可以正常使用了
import matplotlib.font_manager
a = sorted([f.name for f in matplotlib.font_manager.fontManager.ttflist])
for i in a:
    print(i)
相关推荐
扛枪的书生23 分钟前
Linux 网络管理器用法速查
linux
顺风尿一寸3 小时前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
XIAOHEZIcode9 小时前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫11 小时前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux
AlfredZhao2 天前
生产环境里,为什么不建议把普通端口直接暴露到公网?
linux·https·443·80
戴为沐3 天前
Linux内存扩容指南
linux
zylyehuo4 天前
Linux 彻底且安全地删除文件
linux
用户805533698034 天前
主线 U-Boot 上 RK3506:和闭源 rkbin 拔河的三个隐性契约
linux·嵌入式
用户034095297914 天前
linux fcitx 5 雾凇拼音 设置在中文输入法下仍然输入英文标点
linux
Web3探索者6 天前
可视化服务器管理和传统命令行区别是什么?新手教程:Linux 运维到底该用图形界面还是 SSH 命令行?
linux·ssh