在进行模型训练时,出现程序报错情况:
OSError: cannot open resource
此类是常见的字体问题。而服务器并没有这个字体,所以就报错。(服务器显示所有字体命令行:fc-list,显示中文字体命令行:fc-list:lang=zh)如果服务器上没有所要用的字体格式,就需自己下载,然后传输到服务器上。
我们看一下代码需要的字体:
我们需要的是LiberationSans-Regular.ttf
,需要下载。
同时,我们的fc-list也无法显示!我们找到这个路径:
/usr/share/fonts/
发现没有:
如果没有,执行下面指令:
yum -y install fontconfig
检测是否安装了build-essential程序包,输入命令:
apt-get install build-essential
(base) root@I1a0923c597002018a5:/usr/share# apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.8ubuntu1.1).
0 upgraded, 0 newly installed, 0 to remove and 145 not upgraded.
安装yum,输入命令:
apt-get install yum
解决Ubuntu报错 E: Unable to locate package yum
我在学习 Linux 命令的时候需要使用 locate 命令,但是 Ubuntu 的系统里没有安装 locate 命令。根据弹幕的指示我使用了如下命令:
# yum安装locate
sudo yum install mlocate
sudo updatedb
locate -h
然后就会一直出现报错信息yum不存在,我寻思这破服务器咋要啥啥没有,现在看看,确实有点憨。那既然没有yum,就安装呗。于是就出现了题中的问题,属实是骚操作。
————————————————————————————————————————————————————————————
网上查阅资料,全部无用!
开门见山,Ubuntu的包管理工具是apt-get,所以不必再安装yum。
(base) root@I1a0923c597002018a5:/usr/share# apt-get -y install fontconfig
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
fontconfig-config fonts-dejavu-core libfontconfig1 libfreetype6 libpng16-16
The following NEW packages will be installed:
fontconfig fontconfig-config fonts-dejavu-core libfontconfig1 libfreetype6 libpng16-16
0 upgraded, 6 newly installed, 0 to remove and 145 not upgraded.
Need to get 1875 kB of archives.
After this operation, 5109 kB of additional disk space will be used.
Get:1 https://repo.huaweicloud.com/ubuntu focal/main amd64 libpng16-16 amd64 1.6.37-2 [179 kB]
Get:2 https://repo.huaweicloud.com/ubuntu focal-updates/main amd64 libfreetype6 amd64 2.10.1-2ubuntu0.3 [341 kB]
Get:3 https://repo.huaweicloud.com/ubuntu focal/main amd64 fonts-dejavu-core all 2.37-1 [1041 kB]
Get:4 https://repo.huaweicloud.com/ubuntu focal/main amd64 fontconfig-config all 2.13.1-2ubuntu3 [28.8 kB]
Get:5 https://repo.huaweicloud.com/ubuntu focal/main amd64 libfontconfig1 amd64 2.13.1-2ubuntu3 [114 kB]
Get:6 https://repo.huaweicloud.com/ubuntu focal/main amd64 fontconfig amd64 2.13.1-2ubuntu3 [171 kB]
Fetched 1875 kB in 0s (4382 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libpng16-16:amd64.
(Reading database ... 32689 files and directories currently installed.)
Preparing to unpack .../0-libpng16-16_1.6.37-2_amd64.deb ...
Unpacking libpng16-16:amd64 (1.6.37-2) ...
Selecting previously unselected package libfreetype6:amd64.
Preparing to unpack .../1-libfreetype6_2.10.1-2ubuntu0.3_amd64.deb ...
Unpacking libfreetype6:amd64 (2.10.1-2ubuntu0.3) ...
Selecting previously unselected package fonts-dejavu-core.
Preparing to unpack .../2-fonts-dejavu-core_2.37-1_all.deb ...
Unpacking fonts-dejavu-core (2.37-1) ...
Selecting previously unselected package fontconfig-config.
Preparing to unpack .../3-fontconfig-config_2.13.1-2ubuntu3_all.deb ...
Unpacking fontconfig-config (2.13.1-2ubuntu3) ...
Selecting previously unselected package libfontconfig1:amd64.
Preparing to unpack .../4-libfontconfig1_2.13.1-2ubuntu3_amd64.deb ...
Unpacking libfontconfig1:amd64 (2.13.1-2ubuntu3) ...
Selecting previously unselected package fontconfig.
Preparing to unpack .../5-fontconfig_2.13.1-2ubuntu3_amd64.deb ...
Unpacking fontconfig (2.13.1-2ubuntu3) ...
Setting up libpng16-16:amd64 (1.6.37-2) ...
Setting up fonts-dejavu-core (2.37-1) ...
Setting up fontconfig-config (2.13.1-2ubuntu3) ...
Setting up libfreetype6:amd64 (2.10.1-2ubuntu0.3) ...
Setting up libfontconfig1:amd64 (2.13.1-2ubuntu3) ...
Setting up fontconfig (2.13.1-2ubuntu3) ...
Regenerating fonts cache... done.
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
这样再检查:
文件已经存在!
sudo cp /root/glsan-main/LiberationSans-Regular.ttf /usr/share/fonts
这样字体便导入了!不在报错!