首页 > 解决方案 > XML 安装似乎失败并且未在 R 上加载

问题描述

在安装并尝试加载一些用于生物数据分析的软件包时,我不断收到一条错误消息

Error: package or namespace load failed for ‘DESeq2’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘XML’

然后我手动安装了 XML 包:

install.packages("XML")

它打印了这个:

There is a binary version available but the source version is later:
      binary   source needs_compilation
XML 3.99-0.4 3.99-0.5              TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) yes
installing the source package ‘XML’
trying URL 'https://cran.rstudio.com/src/contrib/XML_3.99-0.5.tar.gz'
Content type 'application/x-gzip' length 968563 bytes (945 KB)
downloaded 945 KB

* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/private/var/folders/rp/6tc118312dd069l9827kcfk40000gq/T/RtmpiQB0wX/R.INSTALLd016cd4140e/XML':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘XML’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/XML’
Warning in install.packages :
  installation of package ‘XML’ had non-zero exit status
The downloaded source packages are in
    ‘/private/var/folders/rp/6tc118312dd069l9827kcfk40000gq/T/RtmpZZUrSn/downloaded_packages’

然后当我用库(XML)加载包时:

Error in library(xml) : there is no package called ‘xml’

许多其他包(如 data.table 等)都发生了这种情况

标签: rxml

解决方案


在您的情况下,C 编译器无法正常工作:

checking whether the C compiler works... no

尝试安装以前的版本(例如:)3.99-0.4和/或手动安装。

从 Cran 下载:https ://cran.r-project.org/src/contrib/Archive/XML/

您可以使用以下命令手动安装软件包

install.packages('package.tar.gz', lib='destination_directory_of_downloaded_package',repos = NULL)

请参阅 的帮助以?install.packages获取更多说明。

安装后检查包是否可用:

installed.packages()[1:5,]

推荐阅读