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)
相关推荐
天空之外136几秒前
生成一个带 IP 的自签证书、制作Http证书
linux·运维·服务器
释怀不想释怀26 分钟前
linux常见安装(JDK,mysql,nginx)
linux·运维·服务器
杰克崔29 分钟前
do_exit的hungtask问题及coredump的实验及原理分析一
linux·运维·服务器·车载系统
pengdott36 分钟前
Linux进程数据结构与组织方式深度解析
linux·运维·服务器
Java 码农36 分钟前
gitlab gitrunner springboot 多环境多分支部署 (非容器方式,使用原生linux 环境)
linux·spring boot·gitlab
LongQ30ZZ1 小时前
Linux的常见指令
linux·服务器
走向IT1 小时前
vdbench在Centos系统上联机测试环境搭建
linux·运维·centos
阳宗德1 小时前
基于CentOS Linux release 7.1实现了Oracle Database 11g R2 企业版容器化运行
linux·数据库·docker·oracle·centos
liulilittle1 小时前
libxdp: No bpffs found at /sys/fs/bpf
linux·运维·服务器·开发语言·c++
Byte Beat1 小时前
ubuntu安装docker
linux·ubuntu·docker