Ubuntu findfont: Font family ‘SimHei‘ not found.

2024-01-24 06:12

本文主要是介绍Ubuntu findfont: Font family ‘SimHei‘ not found.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

matplotlib中文乱码显示

当我们遇到这样奇怪的问题时, 结果往往很搞笑

尝试1不行

Stopping Jupyter
Installing font-manager: sudo apt install font-manager
Cleaning the matplotlib cache directory: rm ~/.cache/matplotlib -fr
Restarting Jupyter.

尝试2

This work for me::$ sudo apt-get install msttcorefonts -qq

尝试2, 手工下载字体文件并上传也不行

也反复删除缓存文件了 !rm -rf ~/.cache/matplotlib

最后经过不懈努力, 发现原来目录放错了, 一开始通过jupyter 选择的kernal不知道啥时候变成了基础的了, 导致通过如下方法获取的目录是 3.10的

import matplotlib
print(matplotlib.__file__)

查询字体, 发现路径

print(matplotlib.font_manager.findfont('SimHei'))

但是后来偶尔发现原来目录是3.8

那么问题就解决了, 把字体文件复制到正确的目录 /home/hadoop/anaconda3/envs/mmpose/lib/python3.8/site-packages/matplotlib/mpl-data/fonts/ttf/

这个时候发现仍然报错, 重启一下kernal, 一切正常了

这里面怎么去定义字体有各种方法, 都尝试了还是不行, 但是别人没有遇到问题而我遇到了, 那么说明我的环境是有问题的, 首先想到放对地方了吗

import matplotlib 
import matplotlib.pyplot as pltplt.plot([1, 2, 3, 4])
plt.title('自定义标题名称', fontproperties='SimHei')
plt.show()

这篇关于Ubuntu findfont: Font family ‘SimHei‘ not found.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/638746

相关文章

yum install 失败报错`XZ_5.1.2alpha' not found (required by /lib64/librpmio.so.3)

/export/env/py3.6/lib/liblzma.so.5: version `XZ_5.1.2alpha' not found (required by /lib64/librpmio.so.3)   到/export/env/py3.6/lib cp /lib64/liblzma.so.5.2.2 . sudo ln -s -f liblzma.so.5.2.2 liblzm

BD错误集锦1——[Hive]ERROR StatusLogger No log4j2 configuration file found. Using default configuration:

错误描述:在使用IDEA进行jdbc方式连接到hive数据仓库时,出现以下错误:                ERROR StatusLogger No log4j2 configuration file found. 问题原因:缺少log4j2.xml文件   <?xml version="1.0" encoding="UTF-8"?><Configuration><Appender

# bash: chkconfig: command not found 解决方法

bash: chkconfig: command not found 解决方法 一、chkconfig 错误描述: 这个错误表明在 Bash 环境下,尝试执行 chkconfig 命令,但是系统找不到这个命令。chkconfig 命令是一个用于管理 Linux 系统中服务的启动和停止的工具,通常它是 initscripts 包的一部分,但在最新的 Linux 发行版中可能已经被 syste

crontab: command not found

[root@localhost syweb-sdkapi-new_manager]# crontab -e -bash: crontab: command not found 解决方法: yum install vixie-cron yum install crontabs service crond start           /etc/init.d/crond

在Ubuntu 14.04上安装和配置SNMP守护程序和客户端的方法

前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到网站。 介绍 作为系统管理员的重要工作之一是收集关于服务器和基础设施的准确信息。有许多工具和选项可用于收集和处理这种类型的信息。其中许多工具都是建立在一种叫做 SNMP 的技术之上。 SNMP 代表简单网络管理协议。它是服务器可以共享关于其当前状态的信息的一种方式,也是管理员可以修改预定义值的通道。虽

no thread-bound request found:are you referring to request

问题描述: 通过webservice接口调用程序时,发现在执行查询的时候一直报一个错误,错误信息如下: java.lang.IllegalStateExceptino:No thread-bound request found:are you referring to request attributes outside of an actual web request,or processi

Ubuntu 16.04 Qt5安装qtcharts

Qtcreator5.5安装qchart,首先下载qtcharts,然后进入该路径下,qmake一下。 $git clone https://github.com/qtproject/qtcharts.git $cd qtcharts $qmake 这时会出现问题是’qtConfig’ is nit a recongnized test function 这时输入: $git che

在Ubuntu 12.04 LTS上安装Python3.4.x

在Ubuntu 12.04 LTS上安装Python3.4.x 想重新把python捡起来继续学习,顺便学习下linux的基本操作,所以在ubuntu上面配置了一下python3的环境,找了不少教程,找到一篇很不错的! 原文链接在Ubuntu 12.04 LTS上安装Python3.3.x 我的python版本是3.4.2,根据教程配置成功。 Python3.3.2是Python3最

vue dist文件打开index.html报Failed to load resource: net::ERR_FILE_NOT_FOUND

本地正常。打包好的dist文件打开index.html报Failed to load resource: net::ERR_FILE_NOT_FOUND 解决办法: 在webpack.prod.conf.js 中output添加参数publicPath:’./’ 在webpack.base.conf.js里 publicPath: process.env.NODE_ENV === ‘pro

Ubuntu安装火狐Flash Player插件

1、进入官网下载页面选择:.tar.gz,适用于其他Linux。此次文件名为install_flash_player_11_linux.x86_64.tar.gz 2、解压文件 tar -zxvf install_flash_player_11_linux.x86_64.tar.gz 3、利用whereis命令查找mozilla文件夹的路径 whereis mozill