无法在新Ubuntu设备上安装R软件包

dz6r00yl  于 2022-12-17  发布在  其他
关注(0)|答案(1)|浏览(419)

我是一名医学博士(所以完全没有计算机科学背景),开始参与大数据集的生物信息学分析,过去曾在我的私人Windows笔记本电脑上使用R,没有任何问题。
我的部门现在买了一台新的功能强大的笔记本电脑来加快分析速度,我们的生物信息学核心设备推荐使用Linux系统(我以前从来没有真正用过),所以现在我有了一台很棒的Ubuntu笔记本电脑,但我对刚刚设置好我的R环境开始工作感到有点沮丧。我听说Linux需要一些时间来适应,我我准备好迎接挑战,并想试着理解我在做什么。
所以我的问题是我不能真正在R中安装某些软件包。正如我所说,笔记本电脑是全新的,安装R和RStudio是我在没有改变笔记本电脑基本设置的情况下做的第一件事之一。所以我非常惊讶,我总是在安装这些软件包这样简单的事情上遇到错误。出于某种原因,一些软件包像

install.packages("tidyverse")

工作很好,而其他人失败。所以

install.packages("devtools")

提供以下输出

Installing package into ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
also installing the dependencies ‘systemfonts’, ‘textshaping’, ‘ragg’, ‘pkgdown’

trying URL 'https://cloud.r-project.org/src/contrib/systemfonts_1.0.4.tar.gz'
Content type 'application/x-gzip' length 81757 bytes (79 KB)
==================================================
downloaded 79 KB

trying URL 'https://cloud.r-project.org/src/contrib/textshaping_0.3.6.tar.gz'
Content type 'application/x-gzip' length 35722 bytes (34 KB)
==================================================
downloaded 34 KB

trying URL 'https://cloud.r-project.org/src/contrib/ragg_1.2.4.tar.gz'
Content type 'application/x-gzip' length 427579 bytes (417 KB)
==================================================
downloaded 417 KB

trying URL 'https://cloud.r-project.org/src/contrib/pkgdown_2.0.7.tar.gz'
Content type 'application/x-gzip' length 871465 bytes (851 KB)
==================================================
downloaded 851 KB

trying URL 'https://cloud.r-project.org/src/contrib/devtools_2.4.5.tar.gz'
Content type 'application/x-gzip' length 374718 bytes (365 KB)
==================================================
downloaded 365 KB

* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Package fontconfig was not found in the pkg-config search path.
Perhaps you should add the directory containing `fontconfig.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fontconfig' found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lfontconfig -lfreetype
--------------------------- [ANTICONF] --------------------------------
Configuration failed to find the fontconfig freetype2 library. Try installing:
 * deb: libfontconfig1-dev (Debian, Ubuntu, etc)
 * rpm: fontconfig-devel (Fedora, EPEL)
 * csw: fontconfig_dev (Solaris)
 * brew: freetype (OSX)
If fontconfig freetype2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a fontconfig freetype2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:10: fatal error: fontconfig/fontconfig.h: No such file or directory
compilation terminated.
--------------------------------------------------------------------
ERROR: configuration failed for package ‘systemfonts’
* removing ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2/systemfonts’
Warning in install.packages :
  installation of package ‘systemfonts’ had non-zero exit status
ERROR: dependency ‘systemfonts’ is not available for package ‘textshaping’
* removing ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2/textshaping’
Warning in install.packages :
  installation of package ‘textshaping’ had non-zero exit status
ERROR: dependencies ‘systemfonts’, ‘textshaping’ are not available for package ‘ragg’
* removing ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2/ragg’
Warning in install.packages :
  installation of package ‘ragg’ had non-zero exit status
ERROR: dependency ‘ragg’ is not available for package ‘pkgdown’
* removing ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2/pkgdown’
Warning in install.packages :
  installation of package ‘pkgdown’ had non-zero exit status
ERROR: dependency ‘pkgdown’ is not available for package ‘devtools’
* removing ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2/devtools’
Warning in install.packages :
  installation of package ‘devtools’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpZcPwU9/downloaded_packages’

在网上找了几天后,我相信有一个问题的目录或访问它们。当我进入

.libPaths()

在R中,它给了我
[1]“/home/碧玉/R/x86_64-pc Linux gnu库/4.2”“/usr/本地库/R/站点库”
[3]“/usr/lib/R/站点库”“/usr/lib/R/库”
所以我开始研究这个问题,并尝试修改这里描述的Renviron文件的R_LIBS_USER部分(How do I change the default library path for R packages),但没有任何成功。
当我尝试安装另一个软件包时,我收到了路径不可写的消息,我认为这可能是一个权限问题。所以我在.libPaths()中显示的四个目录上使用了chmod -R 777(据我所知,它为我提供了这些文件夹的所有权限),但也没有成功。重复重新安装R和RStudio也没有帮助。
不幸的是,我的计算机科学技能很快就发现了自己的极限(老实说,甚至是在终端上工作)。由于我真的不知道我在做什么,而且想在更改这台新笔记本电脑根目录中的文件时这样做,我希望你能帮助我。退出并改回Windows不是我的自我选择:D。
下面是我的sessionInfo():
R版本4.2.2修补(2022年11月10日r83330)平台:x86_64-pc-linux-gnu(64位)运行环境:Ubuntu 20.04.5语言版本
基质产品:默认BLAS:文件/usr/lib/x86_64-Linux操作系统-gnu/blas/libblas.so.3.9.0软件包:/usr/文件库/x86_64-Linux操作系统-gnu/lapack
区域设置:[1] LC_CTYPE=美国英语。UTF-8 LC_NUMERIC=C LC_TIME=德国英语。UTF-8 LC_COLLATE=美国英语。UTF-8 LC_MONETARY=德国英语。UTF-8
[6]LC_消息=中文.UTF-8 LC_纸张=中文.UTF-8 LC_名称=C LC_地址=C LC_电话=C
[11]LC_测量=去DE.UTF-8 LC_标识=C
随附基础 Package :[1]统计数据图形grDevices实用程序数据集方法库
通过名称空间加载(且未附加):[1]编译器_4.2.2快速Map_1.1.0 cli_3.4.1 html工具_0.5.4工具_4.2.2 rstudioapi_0.14 yaml_2.3.6 rmarkdown_2.19 [9]编译器_1.41 xfun_0.35摘要_0.6.31 rlang_1.0.6评估_0.19
我真的很感激你的帮助!
多谢了
碧玉

cuxqih21

cuxqih211#

我最近在尝试在Kali Linux虚拟机上安装devtools时遇到了同样的问题。
我解决这个问题的方法是直接从linux命令行(终端)安装dev工具,使用:

sudo apt-get install r-cran-devtools

这在Ubuntu上也应该能用,祝你好运。

相关问题