在没有 root 权限的集群上无法安装 nloptr/nlopt

4

我正在尝试在基于Linux的集群上安装R包FactoMineR,它需要nloptr,而nloptr又需要nlopt。仅使用install.packages("nloptr")无法工作,并产生以下错误:

> install.packages("nloptr")
Installing package into ‘/beegfs/group/home/username/.R/3.3.2/R_LIBS_USER’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/x-gzip' length 353957 bytes (345 KB)
==================================================
downloaded 345 KB

* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for pkg-config... yes
configure: Now testing for NLopt header file.
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking nlopt.h usability... no
checking nlopt.h presence... no
checking for nlopt.h... no
configure: Need to download and build NLopt
trying URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Error in download.file(url = "http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz",  : 
  cannot open URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Execution halted
/usr/bin/gtar: This does not look like a tar archive

gzip: stdin: unexpected end of file
/usr/bin/gtar: Child returned status 1
/usr/bin/gtar: Error is not recoverable: exiting now
Warning message:
In untar(tarfile = "nlopt-2.4.2.tar.gz") :
  '/usr/bin/gtar -xf 'nlopt-2.4.2.tar.gz'' returned error code 2
configure: Starting to install library to /tmp/RtmpazbyAy/R.INSTALL2d6f734a93606/nloptr/nlopt-2.4.2
./configure: line 3325: cd: nlopt-2.4.2: No such file or directory

在这一点上,R会停止工作并需要重新启动。因此,我尝试手动安装nlopt并按照官方网站上的指南进行操作。我将所有内容安装在我的主文件夹中,因为我在集群上没有root权限。但是nloptr安装仍然失败,并出现了找不到nlopt的相同错误。此问题似乎也是如此,但是使用...
install.packages('nloptr', dependencies = TRUE, 
                 configure.args = "--with-nlopt-cflags='-I/$HOME/include' --with-nlopt-libs='-L/$HOME/lib64 -lnlopt'")

仍然产生相同的错误。
文件夹 $HOME/include 包含以下文件: nlopt.f nlopt.h nlopt.hpp,而 $HOME/lib64 包含以下内容: cmake/ libnlopt.so@ libnlopt.so.0@ libnlopt.so.0.9.0* pkgconfig/ python2.7/

我已经尝试了多次并使用了几个相关问题的提示,但迄今为止什么都没有起作用,任何提示都将不胜感激。谢谢!

编辑:有人有想法吗?

3个回答

2
我遇到了类似的错误,但安装github版本对我有用。
https://cran.r-project.org/web/packages/nloptr/README.html上的README中写道:
library(devtools)
devtools::install_github("jyypma/nloptr")

这对我很有帮助。我将nlopt作为模块本地安装,但我不知道是否有所不同;我安装的nlopt版本是2.5.0。

希望这个对你有用!


感谢您提供的解决方案。此外,我安装devtools时不需要sudo。install.packages("devtools") - Murali Podicheti

1

这个问题可能有点老,但我想为将来的参考澄清一下。

当我转移一个使用packrat创建的项目时,遇到了同样的问题,在公司的集群中执行unbundle()时,我发现需要安装nloptr包,正如你所提到的,它只是nlopt库的一个接口。

"NLopt是用于具有和不具有梯度信息的非线性局部和全局优化的库。"

必须在系统中安装此库,并且需要具有root权限。否则,在安装nloptr时会出现错误消息,或者无法完成安装并停留在该阶段,阻止R / Rstudio会话。

我不知道是否有可能为用户进行此库的“本地”安装,并使用它来安装nloptr或任何其他依赖它的软件包。

我唯一看到的解决方案是您应该联系IT经理并要求他安装它。

我希望我已经表达清楚并能够提供一些帮助。


0

如果您在集群中无法使用install.packages("nloptr")安装R包,我建议尝试以下两种方法。

  1. 本地安装该软件包

    • 首先加载您想要安装软件包的R版本的模块;
    • 下载软件包“nloptr_1.0.4.tar.gz”并将其保存到VSC中的目录中;
    • 接下来,确保您在包含软件包的目录中;
    • 最后,在R之外运行命令R CMD install nloptr_1.0.4.tar.gz
  2. 尝试通过运行命令直接加载NLopt模块: module load Nlopt/2.4.2-foss-2015a 通常情况下它会起作用,否则您必须联系技术人员以帮助您使用C++构建它。


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