Jupyter R Docker 安装 systemfonts 时出现致命错误

4
我正在Docker上运行Jupyterlabs,想要安装rvg包。其中一个依赖项是systemfonts,当我尝试使用install.packages("systemfonts")进行安装时,出现以下错误:
Warning: unable to access index for repository https://cran.yu.ac.kr/src/contrib:
  cannot open URL 'https://cran.yu.ac.kr/src/contrib/PACKAGES'
Warning message:
package ‘systemfonts’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

所以我从CRAN下载了tar.gz文件并从文件安装,但是出现致命错误:

    > install.packages("systemfonts_1.0.2.tar.gz", repo = NULL, type = "source")
* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=
Using PKG_LIBS=-lfontconfig -lfreetype
** libs
rm -f systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o font_fallback.o string_metrics.o emoji.o cache_store.o init.o unix/FontManagerLinux.o
x86_64-conda-linux-gnu-c++ -std=gnu++11 -I"/opt/conda/lib/R/include" -DNDEBUG  -I'/opt/conda/lib/R/library/cpp11/include' -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /opt/conda/include -I/opt/conda/include -Wl,-rpath-link,/opt/conda/lib   -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /opt/conda/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/r-base-split_1607284869564/work=/usr/local/src/conda/r-base-4.0.3 -fdebug-prefix-map=/opt/conda=/usr/local/src/conda-prefix  -c caches.cpp -o caches.o
In file included from caches.h:7,
                 from caches.cpp:1:
ft_cache.h:9:10: fatal error: ft2build.h: No such file or directory
    9 | #include <ft2build.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [/opt/conda/lib/R/etc/Makeconf:181: caches.o] Error 1
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/opt/conda/lib/R/library/systemfonts’
Warning message:
In install.packages("work/corehead_data/systemfonts_1.0.2.tar.gz",  :
  installation of package ‘work/corehead_data/systemfonts_1.0.2.tar.gz’ had non-zero exit status

我尝试按照 SO Post中的步骤操作,输入sudo apt-get install -y libfreetype6以获取freetype,但它已经是最新版本了。我不确定还能尝试什么,希望有人能提供一些专业知识。谢谢。
1个回答

3
在搜索“ft2build.h: No such file or directory Ubuntu”时,会导致系统字体库GitHub上的此问题,其中展示了针对Ubuntu 20.04编译错误的解决方法。
sudo apt-get update
sudo apt-get install libfontconfig1-dev

这应该能帮助你从 tar.gz 源代码编译库。

嗨@krassowski,我尝试了一下,但是收到了这个消息:Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package libfontconfig1-dev;然后我尝试了没有-dev的版本:Building dependency tree Reading state information... Done libfontconfig1已经是最新版本(2.13.1-2ubuntu3)。libfontconfig1设置为手动安装。0个升级,0个新安装,0个要删除,0个未升级。 - Spencer Trinh
那个 GitHub 帖子提到了通过 Brew 重新安装 freetype,我尝试安装 freetype,但它已经是最新版本了。 - Spencer Trinh
你使用的是哪个版本的Ubuntu? - krassowski
如果您正在使用Ubuntu 20.04,则可以使用此软件包:https://launchpad.net/ubuntu/focal/+package/libfontconfig1-dev。也许您需要先运行“sudo apt update”?很抱歉,但在这一点上,此问题与JupyterLab、IRkernel甚至是R无关,它只是一个Ubuntu配置问题,超出了我的专业范围。 - krassowski
您的建议很有用。我随后成功安装了 libfontconfig1-dev。非常感谢您! - Spencer Trinh
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接