我是一名医学博士(所以完全没有计算机科学背景),开始参与大数据集的生物信息学分析,过去在我的私人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-library/4.2";/usr/local/lib/R/site-library">
[3]/usr/lib/R/site-library"/usr/lib/R/library"
所以我开始研究这个,并试图修改R_LIBS_USER部分的Renviron文件描述在这里(我如何改变默认库路径为R包)没有任何成功。
当我尝试安装另一个包时,我得到的消息是路径不可写,我读到这可能是一个权限问题。因此,我在四个目录上使用了used chmod -R 777(据我所知,这给了我对这些文件夹的所有权限),这些目录显示了. libpaths(),但也没有成功。反复重新安装R和RStudio也没有帮助。
不幸的是,我的计算机科学技能很快就发现了极限(老实说,即使是使用终端)。因为我真的不明白我在做什么,我想在改变这台新笔记本电脑根目录下的文件时这样做,我希望你能帮助我。退出并切换回Windows对我来说不是一个选择:D .
下面是我的sessionInfo():
R version 4.2.2补丁(2022-11-10 r83330)平台:x86_64-pc-linux-gnu(64位)在Ubuntu 20.04.5 LTS下运行
矩阵乘积:默认bla/libblas.so.3.9.0布拉斯特区:/usr/lib/x86_64-linux-gnu/LAPACK:/usr/lib/x86_64-linux-gnu/LAPACK/liblapack.so.3.9.0
语言环境:[1] LC_CTYPE = en_US。UTF-8 LC_NUMERIC=C LC_TIME=de_DE。utf - 8 LC_COLLATE = en_US。utf - 8 LC_MONETARY = de_DE。UTF-8
[6] LC_MESSAGES=en_US。utf - 8 LC_PAPER = de_DE。UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=de_DE。utf - 8 LC_IDENTIFICATION = C附加的基础包:[1] stats graphics grDevices utils datassets methods base
通过命名空间加载(没有附加):[1] compiler_4.2.2 fastmap_1.1.0 cli_3.4.1 htmltools_0.5.4 tools_4.2.2 rstudioapi_0.14 yaml_2.3.6 rmarkdown_2.19[9] knitr_1.41 xfun_1 .35 digest_1 .6.31 rlang_1.0.6 evaluate_1 .19
我真的很感激你的帮助!谢谢你,
碧玉
我最近在kali linux虚拟机上安装devtools时遇到了同样的问题。
我绕过它的方法是直接从linux命令行(终端)安装dev工具,使用:sudo apt-get install r-cran-devtools
这应该也能在Ubuntu上工作。好运。