如何修复 R 包安装致命错误:png.h: No such file or directory

问题:

安装某些 R 包时,你看到类似这样的错误消息

png_error_output.txt
/bin/bash: libpng-config: command not found
read.c:3:10: fatal error: png.h: No such file or directory
    3 | #include
      |          ^~~~~~~
compilation terminated.
make: *** [/usr/lib/R/etc/Makeconf:168: read.o] Error 1

解决方案

你需要安装 libpng 开发头文件。在 Ubuntu 上,你可以使用以下命令安装

install_libpng_dev.sh
sudo apt -y install libpng-dev

按类别查看类似文章: R